git-subtree-dir: vendor/trainer git-subtree-mainline:c7c2956e15git-subtree-split:a2a9f4edcf
19 lines
1004 B
Bash
Executable File
19 lines
1004 B
Bash
Executable File
#!/bin/sh
|
|
# LLM backend for portal-trainer on a local Ollama: prompt on stdin,
|
|
# text on stdout. MODEL, OLLAMA_HOST, NUM_CTX and TIMEOUT override.
|
|
# Thinking is off: the generator wants files, the answerer wants JSONL.
|
|
# The simulator sets SEED (so the same case replays the same way
|
|
# against two versions of a site), FORMAT=json and TEMPERATURE.
|
|
set -eu
|
|
jq -Rs --arg model "${MODEL:-qwen3:8b}" --argjson ctx "${NUM_CTX:-32768}" \
|
|
--argjson temp "${TEMPERATURE:-0.2}" --arg seed "${SEED:-}" --arg format "${FORMAT:-}" \
|
|
'{model: $model, stream: false, think: false,
|
|
options: ({num_ctx: $ctx, temperature: $temp}
|
|
+ (if $seed == "" then {} else {seed: ($seed | tonumber)} end)),
|
|
messages: [{role: "user", content: .}]}
|
|
+ (if $format == "json" then {format: "json"} else {} end)' |
|
|
curl -sS --fail-with-body --max-time "${TIMEOUT:-1800}" \
|
|
"${OLLAMA_HOST:-http://127.0.0.1:11434}/api/chat" \
|
|
-H "content-type: application/json" --data-binary @- |
|
|
jq -er '.message.content'
|