Files
llm-connect/tests/test_payload.py
tegwick 90eb39c247
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
Complete activity-core LLM endpoint handoff (LLM-WP-0006)
Switch the custodian triage default from anthropic/claude-sonnet-4 to
google/gemini-2.5-flash, which advertises structured-output support on
OpenRouter. Tighten the OpenRouter adapter to send strict JSON schema
requests and set provider.require_parameters=true so routing only hits
providers that honor the requested response_format.

Update Kubernetes deploy docs and config for the verified coulombcore
handoff: Containerfile build path, image-pull-policy=Never for smoke
pods, credential-routing notes, and live smoke evidence. Mark
LLM-WP-0006 finished with closure notes from 2026-06-18.
2026-06-19 13:51:12 +02:00

82 lines
2.3 KiB
Python

from llm_connect._payload import merge_gemini_model_params, merge_openai_chat_model_params
STRUCTURED_SCHEMA = {
"type": "object",
"properties": {
"summary": {"type": "string"},
"recommendations": {"type": "array", "items": {"type": "string"}},
},
"required": ["summary", "recommendations"],
}
ACTIVITY_CORE_MODEL_PARAMS = {
"reasoning_effort": "medium",
"max_depth": 4,
"json_schema": STRUCTURED_SCHEMA,
"top_p": 0.8,
}
def test_openai_chat_model_params_translate_activity_core_shape():
payload = {
"model": "gpt-4.1-mini",
"messages": [{"role": "user", "content": "triage"}],
"temperature": 0.2,
"max_tokens": 200,
}
merge_openai_chat_model_params(payload, ACTIVITY_CORE_MODEL_PARAMS)
assert payload["response_format"] == {
"type": "json_schema",
"json_schema": {
"name": "structured_output",
"schema": STRUCTURED_SCHEMA,
"strict": True,
},
}
assert payload["top_p"] == 0.8
assert "reasoning_effort" not in payload
assert "max_depth" not in payload
assert "json_schema" not in payload
def test_openai_chat_model_params_preserve_explicit_response_format():
explicit = {
"type": "json_schema",
"json_schema": {
"name": "custom",
"schema": STRUCTURED_SCHEMA,
"strict": True,
},
}
payload = {"model": "gpt-4.1-mini", "messages": []}
merge_openai_chat_model_params(
payload,
{"json_schema": STRUCTURED_SCHEMA, "response_format": explicit},
)
assert payload["response_format"] == explicit
def test_gemini_model_params_translate_activity_core_shape():
payload = {
"contents": [{"role": "user", "parts": [{"text": "triage"}]}],
"generationConfig": {
"temperature": 0.2,
"maxOutputTokens": 200,
},
}
merge_gemini_model_params(payload, ACTIVITY_CORE_MODEL_PARAMS)
assert payload["generationConfig"]["responseMimeType"] == "application/json"
assert payload["generationConfig"]["responseSchema"] == STRUCTURED_SCHEMA
assert payload["generationConfig"]["topP"] == 0.8
assert "reasoning_effort" not in payload
assert "max_depth" not in payload
assert "json_schema" not in payload