From 33df0c32f80451c6fe7f20ecb98e5a6d74669324 Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Tue, 7 Apr 2026 17:13:58 -0600 Subject: [PATCH] docs(v4): belated updates from #137 and #138 Signed-off-by: Vaughn Dice --- docs/v4/http/index.html | 57 ++++++++++++++++++++++++++--------------- docs/v4/llm.html | 19 +++++++++----- docs/v4/variables.html | 4 +-- 3 files changed, 52 insertions(+), 28 deletions(-) diff --git a/docs/v4/http/index.html b/docs/v4/http/index.html index 3529c76..556757f 100644 --- a/docs/v4/http/index.html +++ b/docs/v4/http/index.html @@ -45,21 +45,6 @@

Module spin_sdk.http

Functions

-
-async def copy(bytes: bytes, tx: componentize_py_async_support.streams.ByteStreamWriter) -
-
-
- -Expand source code - -
async def copy(bytes:bytes, tx:ByteStreamWriter):
-    with tx:
-        if bytes is not None:
-            await tx.write_all(bytes)
-
-
-
async def send(request: Request) ‑> Response
@@ -112,7 +97,7 @@

Functions

content_length = len(request.body) if request.body is not None else 0 # Make a copy rather than mutate in place, since the caller might not # expect us to mutate it: - headers_dict = headers_dict.copy() + headers_dict = dict(headers_dict) headers_dict['content-length'] = str(content_length) headers = list(map( @@ -121,12 +106,12 @@

Functions

)) tx, rx = wit.byte_stream() - componentize_py_async_support.spawn(copy(request.body, tx)) + componentize_py_async_support.spawn(_copy(request.body, tx)) outgoing_request = WasiRequest.new(Fields.from_list(headers), rx, _trailers_future(), None)[0] outgoing_request.set_method(method) outgoing_request.set_scheme(scheme) if url_parsed.netloc == '': - if scheme == "http": + if isinstance(scheme, Scheme_Http): authority = ":80" else: authority = ":443" @@ -161,6 +146,38 @@

Functions

Send an HTTP request and return a response or raise an error

+
+def strip_forbidden_headers(headers: MutableMapping[str, str]) ‑> MutableMapping[str, str] +
+
+
+ +Expand source code + +
def strip_forbidden_headers(headers:MutableMapping[str, str]) -> MutableMapping[str, str]:
+    """
+    Strips forbidden headers for requests and responses originating from guest apps, per wasmtime/Spin
+    """
+    # See https://github.com/bytecodealliance/wasmtime/blob/e9e1665c5ef150d618bd8c21fb355c063596d6f7/crates/wasi-http/src/lib.rs#L42-L52
+    for header in [
+        "connection",
+        "keep-alive",
+        "proxy-authenticate",
+        "proxy-authorization",
+        "proxy-connection",
+        "transfer-encoding",
+        "upgrade",
+        "host",
+        "http2-settings"
+    ]:
+        try:
+            del headers[header]
+        except KeyError:
+            pass
+    return headers
+
+

Strips forbidden headers for requests and responses originating from guest apps, per wasmtime/Spin

+
@@ -240,7 +257,7 @@

Classes

simple_response.headers['content-length'] = str(content_length) tx, rx = wit.byte_stream() - componentize_py_async_support.spawn(copy(simple_response.body, tx)) + componentize_py_async_support.spawn(_copy(simple_response.body, tx)) response = WasiResponse.new(Fields.from_list(list(map( lambda pair: (pair[0], bytes(pair[1], "utf-8")), simple_response.headers.items() @@ -368,8 +385,8 @@

Instance variables

  • Functions

  • Classes

    diff --git a/docs/v4/llm.html b/docs/v4/llm.html index 3ace272..61356ac 100644 --- a/docs/v4/llm.html +++ b/docs/v4/llm.html @@ -46,14 +46,14 @@

    Module spin_sdk.llm

    Functions

    -def generate_embeddings(model: str, text: Sequence[str]) ‑> EmbeddingsResult +def generate_embeddings(model: str, text: List[str]) ‑> EmbeddingsResult
    Expand source code -
    def generate_embeddings(model: str, text: Sequence[str]) -> spin_llm.EmbeddingsResult:
    +
    def generate_embeddings(model: str, text: List[str]) -> spin_llm.EmbeddingsResult:
         """
         A `componentize_py_types.Err(spin_sdk.wit.imports.fermyon_spin_llm_2_0_0.Error_ModelNotSupported)` will be raised if the component does not have access to the specified model.
         
    @@ -83,8 +83,7 @@ 

    Functions

    A `componentize_py_types.Err(spin_sdk.wit.imports.fermyon_spin_llm_2_0_0.Error_InvalidInput(str))` will be raised if an invalid input is provided. """ - options = InferencingParams - return spin_llm.infer(model, prompt, options)
    + return infer_with_options(model, prompt, None)

    A componentize_py_types.Err(Error_ModelNotSupported) will be raised if the component does not have access to the specified model.

    A componentize_py_types.Err(Error_RuntimeError(str)) will be raised if there are any runtime errors.

    @@ -106,8 +105,16 @@

    Functions

    A `componentize_py_types.Err(spin_sdk.wit.imports.fermyon_spin_llm_2_0_0.Error_InvalidInput(str))` will be raised if an invalid input is provided. """ - options = options or InferencingParams - return spin_llm.infer(model, prompt, options) + some_options = options or InferencingParams() + my_options = spin_llm.InferencingParams( + some_options.max_tokens, + some_options.repeat_penalty, + some_options.repeat_penalty_last_n_token_count, + some_options.temperature, + some_options.top_k, + some_options.top_p, + ) + return spin_llm.infer(model, prompt, my_options)

    A componentize_py_types.Err(Error_ModelNotSupported) will be raised if the component does not have access to the specified model.

    A componentize_py_types.Err(Error_RuntimeError(str)) will be raised if there are any runtime errors.

    diff --git a/docs/v4/variables.html b/docs/v4/variables.html index ac1eb3f..44686a4 100644 --- a/docs/v4/variables.html +++ b/docs/v4/variables.html @@ -46,14 +46,14 @@

    Module spin_sdk.variables

    Functions

    -async def get(key: str) +async def get(key: str) ‑> str
    Expand source code -
    async def get(key: str):
    +
    async def get(key: str) -> str:
         """
         Gets the value of the given key
         """