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>
This commit is contained in:
flemming-it 2026-07-11 23:19:32 +02:00
parent b5389fce45
commit 305ab1cecd
9 changed files with 662 additions and 136 deletions

View file

@ -1,12 +1,12 @@
schema_version: 3
provider: chain
name: llm-chat
version: 0.1.0
version: 0.2.0
# Capability provided by this module.
provides:
- capability: llm.chat
version: 0.1.0
version: 0.2.0
# Declared inputs in verbose v3 form. Studio renders the
# description in the active locale as a tooltip on each
@ -22,11 +22,26 @@ inputs:
type: text
description:
en: |
Ollama-shaped /api/chat endpoint, e.g.
"http://localhost:11434/api/chat".
Chat endpoint URL matching the selected api:
ollama "http://localhost:11434/api/chat",
openai "https://.../v1/chat/completions" (vLLM etc.),
anthropic "https://api.anthropic.com/v1/messages".
de: |
Ollama-kompatibler /api/chat-Endpunkt, z. B.
"http://localhost:11434/api/chat".
Chat-Endpunkt-URL passend zur gewählten api:
ollama "http://localhost:11434/api/chat",
openai "https://.../v1/chat/completions" (vLLM u. a.),
anthropic "https://api.anthropic.com/v1/messages".
api:
type: text
description:
en: |
Optional wire format: "ollama" (default), "openai"
(Chat Completions — OpenAI, vLLM, compatible servers),
or "anthropic" (Messages API). Empty = ollama.
de: |
Optionales Wire-Format: "ollama" (Default), "openai"
(Chat Completions — OpenAI, vLLM, kompatible Server)
oder "anthropic" (Messages API). Leer = ollama.
model:
type: text
description:
@ -36,11 +51,15 @@ inputs:
type: text
description:
en: |
Optional bearer token for cloud-hosted endpoints.
Empty string means no Authorization header is sent.
Optional API key. Sent as "Authorization: Bearer" for
ollama/openai and as "x-api-key" for anthropic. Empty
string means no auth header is sent. Never appears in
outputs, logs, or audit events.
de: |
Optionaler Bearer-Token für Cloud-Endpunkte.
Leer = kein Authorization-Header gesendet.
Optionaler API-Key. Bei ollama/openai als
"Authorization: Bearer", bei anthropic als "x-api-key"
gesendet. Leer = kein Auth-Header. Erscheint nie in
Ausgaben, Logs oder Audit-Events.
system_prompt:
type: text
description: