feat(chat): add response_format passthrough for structured output #60
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_aibroker!60
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_json_schema"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements #59.
Forwards an OpenAI-style
response_formatfield through the broker to upstream providers. Pass-through only — no broker-side schema validation.ChatRequest.response_format: Option<Value>(forwarded unchanged via existing.json(&request)serialisation)OpenAIChatRequest.response_format(REST POST /v1/chat/completions)ai.chatJSON-RPC accepts the new optional paramopenrpc.jsonupdatedUnblocks hero_memory Phases 4 (Q&A) and 5 (ontology) — see hero_memory#1.
Ready to merge once reviewed.
Forwards an OpenAI-style response_format field through the broker to the upstream provider. Enables JSON-schema-constrained completions, which hero_memory's Q&A and ontology extractors depend on (see hero_aibroker#59). - providers/types.rs: ChatRequest gains optional response_format: Option<serde_json::Value>. The OpenAIProvider already serialises ChatRequest directly to the upstream HTTP body, so the field is forwarded unchanged. - server/src/api/chat.rs: OpenAIChatRequest gains response_format and the From<OpenAIChatRequest> for ChatRequest impl carries it across. - server/src/api/mod.rs: handle_ai_chat reads response_format from params. - openrpc.json: ai.chat documents the optional response_format parameter. Pass-through only — no aibroker-side schema validation. Callers send either { "type": "json_schema", "json_schema": {...} } or { "type": "json_object" } according to the upstream provider's spec. Refs hero_aibroker#59 Refs hero_memory#1 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Closing as redundant. Upstream
developmentalready implementsresponse_formatonai.chat(with a typedResponseFormat { kind, json_schema }struct inproviders/types.rsplus the openrpc.json param), as part of the cascade-multi-broker work that landed after I branched. hero_memory will pin todevelopmentdirectly.Closing as already implemented in current
development.response_formatpassthrough was completed via the OpenRouter / chat refactor work that landed after this PR was opened. Mapping against the current tree (commit9a03f20):ChatRequest.response_format: Option<ResponseFormat>(kind + json_schema)crates/hero_aibroker_lib/src/providers/types.rs:205ai.chatJSON-RPC passthrough —serde_json::from_value(params)straight intoChatRequestcrates/hero_aibroker_server/src/api/mod.rs:433/v1/chat/completions— direct deserialize intoChatRequest(the intermediateOpenAIChatRequestwas removed)crates/hero_aibroker_server/src/api/chat.rs:74crates/hero_aibroker_server/openrpc.json:899AiChatInput.response_formatcrates/hero_aibroker_server/openrpc.client.generated.rs:623The current shape is actually a bit better than what this PR proposed — it's typed (
ResponseFormatwithkindandjson_schemafields) rather than a rawOption<Value>, so the OpenRPC schema can document the structure. Linked issue #59 is already closed.Thanks anyway — closing without merging.
Pull request closed