feat(chat): add response_format passthrough for structured output #60

Open
timur wants to merge 1 commit from development_json_schema into development
Owner

Implements #59.

Forwards an OpenAI-style response_format field 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.chat JSON-RPC accepts the new optional param
  • openrpc.json updated

Unblocks hero_memory Phases 4 (Q&A) and 5 (ontology) — see hero_memory#1.

Ready to merge once reviewed.

Implements [#59](https://forge.ourworld.tf/lhumina_code/hero_aibroker/issues/59). Forwards an OpenAI-style `response_format` field 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.chat` JSON-RPC accepts the new optional param - `openrpc.json` updated Unblocks hero_memory Phases 4 (Q&A) and 5 (ontology) — see hero_memory#1. Ready to merge once reviewed.
feat(chat): add response_format passthrough for structured output
Some checks failed
Build and Test / build-and-test (pull_request) Failing after 10s
ebfd358f01
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>
Author
Owner

Closing as redundant. Upstream development already implements response_format on ai.chat (with a typed ResponseFormat { kind, json_schema } struct in providers/types.rs plus the openrpc.json param), as part of the cascade-multi-broker work that landed after I branched. hero_memory will pin to development directly.

Closing as redundant. Upstream `development` already implements `response_format` on `ai.chat` (with a typed `ResponseFormat { kind, json_schema }` struct in `providers/types.rs` plus the openrpc.json param), as part of the cascade-multi-broker work that landed after I branched. hero_memory will pin to `development` directly.
timur closed this pull request 2026-05-06 08:39:08 +00:00
mik-tf reopened this pull request 2026-05-06 17:57:28 +00:00
Some checks failed
Build and Test / build-and-test (pull_request) Failing after 10s
This pull request has changes conflicting with the target branch.
  • crates/hero_aibroker_lib/src/providers/types.rs
  • crates/hero_aibroker_server/openrpc.client.generated.rs
  • crates/hero_aibroker_server/openrpc.json
  • crates/hero_aibroker_server/src/api/chat.rs
  • crates/hero_aibroker_server/src/api/mod.rs
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin development_json_schema:development_json_schema
git switch development_json_schema

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch development
git merge --no-ff development_json_schema
git switch development_json_schema
git rebase development
git switch development
git merge --ff-only development_json_schema
git switch development_json_schema
git rebase development
git switch development
git merge --no-ff development_json_schema
git switch development
git merge --squash development_json_schema
git switch development
git merge --ff-only development_json_schema
git switch development
git merge development_json_schema
git push origin development
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_aibroker!60
No description provided.