F module - Ollama-backed text translation between supported languages.
Port the multi-API client from llm.chat (llm.rs kept in lockstep): the optional api input selects the dialect, default stays the unchanged v0.1.x Ollama behavior. openai covers vLLM, LM Studio, LiteLLM and cloud OpenAI; api-specific error hints; api_key sent as Bearer (ollama/openai) or x-api-key (anthropic). model_digest stays an Ollama-only best-effort probe and is documented as such. Proven end-to-end against a hermetic OpenAI-wire fake (request shape validated, response parsed) via a hub flow run. Signed-off-by: flemming-it <sf@flemming.it> |
||
|---|---|---|
| .forgejo/workflows | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| MODULE.de.md | ||
| MODULE.md | ||
| module.wasm | ||
| module.yaml | ||
| NOTICE | ||
| README.md | ||
| rust-toolchain.toml | ||
text-translate
Provides the text.translate capability for Ch∆In.
Build
cargo build --release --target wasm32-wasip2
Test
cargo test # host-side unit + integration tests
fai test . # load the wasm component in the runtime sandbox
Authoring with chain-module-sdk
The module body is one decorated function:
#[chain_module]
pub fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
let message = inputs.require_text("message")?;
Ok(Outputs::new().with_text("reply", format!("got: {message}")))
}
The macro hides the wit_bindgen call, the Guest impl, the
Payload variant matching, and the wit_bindgen::export!
invocation. See chain-module-sdk documentation for the full
surface.
SDK source
The Cargo.toml git-deps chain-module-sdk from
https://git.flemming.ws/fai/module-sdk.git. If your environment requires
authentication for that host (e.g. Forgejo with
REQUIRE_SIGNIN_VIEW=true), set up git config insteadOf with
your PAT, or use cargo:net.git-fetch-with-cli=true plus a
credential helper.
License
Apache-2.0