feat: initial text-translate v0.1.0 (text.translate@0.1.0)
All checks were successful
CI / Linux x86_64 (Forgejo) (push) Successful in 1m34s
All checks were successful
CI / Linux x86_64 (Forgejo) (push) Successful in 1m34s
Ollama-backed translation module — third real F∆I capability,
following text.extract and llm.chat. Used for the second leg of
a regulated document workflow (extract -> translate -> review
-> summarise).
Capability:
Inputs:
text : text (source text)
target_language : text (e.g. "German", "French")
source_language : text (optional hint; empty = auto)
endpoint : text (Ollama /api/chat URL)
model : text
api_key : text (optional)
Outputs:
translation : text
source_language : text (echo for audit)
target_language : text (echo for audit)
model_endpoint : text
model_name : text
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 translation prompt is conservative: a fixed system prompt
demands faithful translation with structure preservation and
emits no metadata, no quoting. The user prompt names the target
language and (when supplied) the source language. The LLM
client + digest-probe pattern is reused verbatim from llm-chat;
when a third module joins, the shared client moves into a small
crate.
14 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, and
end-to-end skip-for-non-Ollama.
Wasm artifact verified to build with v1.0 fai:platform imports
baked in. Bootstrapped via 'fai new module text.translate'.
Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
commit
a4c2c0e14e
11 changed files with 1440 additions and 0 deletions
48
module.yaml
Normal file
48
module.yaml
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
schema_version: 1
|
||||
name: text-translate
|
||||
version: 0.1.0
|
||||
|
||||
# Capability provided by this module.
|
||||
provides:
|
||||
- capability: text.translate
|
||||
version: 0.1.0
|
||||
|
||||
# Inputs the invoke function accepts.
|
||||
inputs:
|
||||
# Source text to translate.
|
||||
text: text
|
||||
# Target language name in plain English (e.g. "German",
|
||||
# "French", "ja-JP" — anything the configured LLM
|
||||
# understands).
|
||||
target_language: text
|
||||
# Optional source language hint. Empty string lets the model
|
||||
# auto-detect.
|
||||
source_language: text
|
||||
# Ollama-shaped /api/chat endpoint.
|
||||
endpoint: text
|
||||
# Model identifier (e.g. "qwen2.5:14b").
|
||||
model: text
|
||||
# Optional bearer token for cloud-hosted endpoints.
|
||||
api_key: text
|
||||
|
||||
# Outputs produced.
|
||||
outputs:
|
||||
# The translated text.
|
||||
translation: text
|
||||
# Echo of the source-language input for downstream audit.
|
||||
source_language: text
|
||||
# Echo of the target-language input.
|
||||
target_language: text
|
||||
# Endpoint the translation was generated against.
|
||||
model_endpoint: text
|
||||
# Model identifier as supplied to the LLM API.
|
||||
model_name: text
|
||||
# SHA-256 digest of the served Ollama model (when reachable).
|
||||
model_digest: text
|
||||
|
||||
# Permissions required.
|
||||
permissions:
|
||||
- "net: localhost"
|
||||
- "net: 127.0.0.1"
|
||||
- "net: api.openai.com"
|
||||
- "net: api.anthropic.com"
|
||||
Loading…
Add table
Add a link
Reference in a new issue