Commit graph

11 commits

Author SHA1 Message Date
6455a7457e feat: think input switches the thinking phase of reasoning models, 0.3.1
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
Ollama gets think, vLLM chat_template_kwargs.enable_thinking. Refused
where the backend has no such switch.

Signed-off-by: flemming-it <sf@flemming.it>
2026-11-07 23:24:28 +01:00
d5b000e18e feat: report what a call cost in tokens
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>
2026-10-26 03:54:39 +01:00
Stefan Flemming
a6fe962916 feat: sampling options (temperature, top_p, top_k, seed)
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
aila asked for these twice (07.08. and 08.08.) and worked around it
by baking the values into a derived Ollama model, which is the only
way they could get a reproducible pipeline.

Verified against a live Ollama: two runs with `temperature: "0"` and
`seed: "42"` return the same answer.

Each wire format gets what it actually supports, and an option the
wire does not have is REFUSED rather than dropped: `top_k` on the
OpenAI wire, `seed` on Anthropic. A silently ignored setting
produces a run that looks configured and is not, which is worse than
an error, especially for `seed`, where the whole point is being able
to repeat the run. A non-numeric value is an error too, so a typo
cannot pass as "server default".

Unset leaves the request byte-identical to 0.2.1, so no existing
caller sees a change.

Eight guards covering all three wires, both refusals, the
unset case, and that `seed` stays a whole number.

Capability 0.2.1 to 0.2.2: four optional inputs, nothing removed.

Signed-off-by: Stefan Flemming <stefan.a.flemming@googlemail.com>
2026-10-16 20:47:40 +02:00
9483f196a1 feat: keep_alive input so a local model stays resident
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
Ollama unloads a model five minutes after its last request, and the
next request then pays a full reload: 30 to 40 seconds for a large
local model, long enough that an operator assumes something is broken.
The stromnetz demonstrator runs on a notebook from around 12.10. and
hits exactly that after any idle period; it works around it today by
setting OLLAMA_KEEP_ALIVE on the server, which is not expressible in a
flow.

Measured against a live Ollama: without the input the model expired
5:02 after the request, with `keep_alive: "90s"` it expired after 92
seconds. Worth knowing for callers: Ollama keeps the value for the
loaded instance, so a later request that omits keep_alive does not
fall back to five minutes until the model has actually been unloaded.

`-1` is sent as a number rather than a string, because Ollama reads
only the numeric form as "never unload"; quoted it is parsed as a
duration and the setting silently does nothing.

With any other wire format the input is REFUSED, not ignored. It
expresses an expectation about the server, and dropping it quietly
would leave the caller paying the reload while believing it was
handled. The message says what to do instead.

Capability goes 0.2.0 to 0.2.1: the addition is optional and additive,
so `@^0.2` and `@^0` both keep resolving, and an unset value leaves
the request byte-identical to the previous version.

Five guards, including that unset omits the field entirely and that
the other wire formats never carry it. Mutation-checked three ways.

Signed-off-by: flemming-it <sf@flemming.it>
2026-10-07 05:49:16 +02:00
dd7b419d37 chore: cargo fmt
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
Signed-off-by: flemming-it <sf@flemming.it>
2026-08-20 22:30:33 +02:00
b5ceaa3dfe feat: api accepts 'vllm' as a first-class value
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
sign-bundle / sign (push) Failing after 1m53s
'openai' reads as the cloud company — an operator running
self-hosted vLLM should be able to write what they mean. The new
value speaks the identical OpenAI wire (a guard test asserts the
emitted request stays byte-identical to api: openai, so the alias
can never drift into a dialect) but yields vLLM-specific error
hints (vllm serve, port 8000) instead of generic OpenAI prose.
Manifest + docs name the value in DE and EN.

Signed-off-by: flemming-it <sf@flemming.it>
2026-08-20 17:13:44 +02:00
305ab1cecd feat: OpenAI and Anthropic wire-format adapters via new api input
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
sign-bundle / sign (push) Has been cancelled
New optional input api: ollama|openai|anthropic (default ollama —
existing flows unchanged).

- openai: OpenAI Chat Completions format (/v1/chat/completions),
  Bearer auth — targets vLLM and compatible self-hosted servers.
- anthropic: Messages API (/v1/messages), x-api-key +
  anthropic-version headers, top-level system field, mandatory
  max_tokens (fixed 4096).
- Audit outputs unchanged: model_endpoint/model_name always set;
  model_digest stays Ollama-only (no digest API on openai/anthropic,
  field is left empty rather than fabricated).
- api_key is only ever placed in auth headers; never in outputs,
  errors, or audit events (verified against the event log).
- No streaming, no tool calls.

Bump module + capability version to 0.2.0. Wire-format unit tests
for request serialization and response parsing against fixed JSON
fixtures; live smoke green on the ollama path and on the openai
path against an OpenAI-compatible local endpoint.

Signed-off-by: flemming-it <sf@flemming.it>
2026-07-11 23:19:32 +02:00
b5389fce45 chore(build): pin chain-module-sdk v0.3.0 and adopt #[chain_module]
SDK 0.3.0 drops the fai-legacy #[fai_module] alias; pin the tag and
flip the attribute, rebuilt module.wasm accordingly.

Signed-off-by: flemming-it <sf@flemming.it>
2026-07-11 23:12:39 +02:00
18a84ef4cb fix: clear Ollama-unreachable error naming the endpoint + fix hint
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
Signed-off-by: flemming-it <sf@flemming.it>
2026-07-07 19:18:24 +02:00
d5894c7bd4 refactor: depend on renamed chain-module-sdk
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 1s
Signed-off-by: flemming-it <sf@flemming.it>
2026-06-16 11:28:12 +02:00
4c10a5ff3d feat: initial llm-chat v0.1.0 (llm.chat@0.1.0)
All checks were successful
CI / Linux x86_64 (Forgejo) (push) Successful in 1m57s
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>
2026-05-03 23:17:36 +02:00