Three dialects spell the same two numbers differently: Ollama counts in `prompt_eval_count` and `eval_count`, the OpenAI shape in `usage.prompt_tokens` and `usage.completion_tokens`, Anthropic in `usage.input_tokens` and `usage.output_tokens`. All three now reach the caller as `tokens_prompt` and `tokens_completion`, which the hub lifts into the audit log by itself. An answer that carries no count leaves both fields empty rather than reporting a zero: a zero is a measurement, and this is the absence of one. Half a count is reported as far as it goes. The cost of a model call was the one part of the audit question "which model produced this, and what did it cost" that nothing answered (model pool M3). 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 | ||
llm-chat
F∆I module providing the llm.chat capability — a generic
LLM chat adapter speaking Ollama (default), OpenAI Chat
Completions (OpenAI, vLLM, compatible servers), and the
Anthropic Messages API, selected via the optional api input.
Capability
| Field | Value |
|---|---|
| Capability | llm.chat@0.2.0 |
| Inputs | prompt: text, endpoint: text, model: text, api_key: text (opt), system_prompt: text (opt), api: text (opt: ollama|openai|anthropic) |
| 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. Ch∆In
docs/advanced/compliance-gaps.md Gap 1.
Build
cargo build --release --target wasm32-wasip2
Test
cargo test # wire-format unit tests, all host-side
cargo build --release --target wasm32-wasip2
SDK source
The Cargo.toml git-deps chain-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 chain@flemming.ai Repository: https://git.flemming.ws/chain-modules/llm-chat