Generic Ollama-compatible LLM chat adapter. The lower-level
counterpart to orchestrator-llm: orchestrator-llm wraps the LLM
in a planning prompt that emits a structured F∆I Plan; this
module is the plain-prompt adapter that flows compose for
summarisation, translation, free-form Q&A, etc.
Capability surface:
Inputs:
prompt : text
endpoint : text (Ollama /api/chat URL)
model : text
api_key : text (optional bearer token)
system_prompt : text (optional)
Outputs:
response : text (assistant reply)
model_endpoint : text (audit correlation)
model_name : text (audit correlation)
model_digest : text (Ollama /api/show probe; empty
for non-Ollama or transient failures)
Permissions: net to localhost / 127.0.0.1 / api.openai.com /
api.anthropic.com.
The audit-field trio (endpoint + name + digest) closes the same
forensic gap that orchestrator-llm v0.3.1 closed for plan
generation: any historical chat invocation can be traced to the
exact model that produced it.
Implementation reuses the same defensive Ollama client pattern
from orchestrator-llm — derive_show_url + extract_show_digest
+ best-effort probe_model_digest. Duplication accepted at the
two-module mark; a shared crate refactor lands once a third
module needs the same plumbing.
12 host-side tests cover prompt building, Ollama-shaped
response parsing, URL transform, digest extraction (top-level
+ nested), end-to-end success, end-to-end probe-failure
swallow, end-to-end skip-for-non-Ollama, and the missing-input
guards.
Wasm artifact: 294 KB. Verified to build with v1.0 fai:platform
imports baked in.
Bootstrapped via 'fai new module llm.chat' (workspace v0.10.13)
which now produces an SDK-based template directly.
Signed-off-by: flemming-it <sf@flemming.it>
2 KiB
llm-chat
F∆I module providing the llm.chat capability — a generic
Ollama-compatible LLM chat adapter.
Capability
| Field | Value |
|---|---|
| Capability | llm.chat@0.1.0 |
| Inputs | prompt: text, endpoint: text, model: text, api_key: text (opt), system_prompt: text (opt) |
| Outputs | response: text, model_endpoint: text, model_name: text, model_digest: text |
| Permissions | net: localhost, net: 127.0.0.1, net: api.openai.com, net: api.anthropic.com |
| Status (in store index) | alpha |
Why a separate module from orchestrator-llm
orchestrator-llm wraps an LLM call inside a planning prompt
that emits a structured F∆I Plan. llm.chat is the lower-
level adapter: it sends a prompt and returns the assistant text
verbatim. Flows that need a generic chat step (summarisation,
translation, free-form Q&A) compose llm.chat directly; flows
that need plan generation use orchestrator-llm.
Audit fields
model_endpoint, model_name, and model_digest are emitted
on every successful invocation. Together they answer the audit
question "which exact model produced this response?" The digest
probe targets Ollama's /api/show and is best-effort — non-
Ollama endpoints and transient probe failures yield an empty
digest rather than blocking the response. Cf. F∆I Platform
docs/advanced/compliance-gaps.md Gap 1.
Build
cargo build --release --target wasm32-wasip2
Test
cargo test # 11 tests, all host-side
cargo build --release --target wasm32-wasip2
SDK source
The Cargo.toml git-deps fai-module-sdk from
https://git.flemming.ws/fai/module-sdk.git. The Forgejo
instance has REQUIRE_SIGNIN_VIEW=true, so anonymous clones
fail; CI uses the MODULE_SDK_PAT actions secret + git config url.X.insteadOf Y to authenticate cargo's git fetch
transparently. Local dev uses the same pattern via env vars.
License
Apache-2.0.
Author: Dr. Stefan Flemming, Flemming.AI platform@flemming.ai Repository: https://git.flemming.ws/fai-modules/llm-chat