Added json_schema support - #47
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Reviewer's GuideAdds OpenAI-compatible json_schema response_format support end-to-end, wiring a JSON Schema from the chat request into the Claude CLI via --json-schema, and preferring structured result content in both streaming and non‑streaming responses when json_schema is used, plus a convenience Docker Compose file. Sequence diagram for json_schema propagation and result preferencesequenceDiagram
actor Client
participant API as create_chat_completion
participant Manager as ClaudeManager.create_session
participant Start as ClaudeManager.start
participant CLI as Claude_CLI
participant StreamResp as create_sse_response
participant NonStreamResp as create_non_streaming_response
Client->>API: ChatCompletionRequest(response_format.json_schema)
API->>API: _extract_json_schema(request)
API->>Manager: create_session(prompt, model, system_prompt, json_schema)
Manager->>Start: start(prompt, model, system_prompt, json_schema)
Start->>CLI: run --json-schema <json_schema>
alt request.stream
API->>StreamResp: create_sse_response(..., prefer_result_content=json_schema is not None)
StreamResp->>StreamResp: OpenAIStreamConverter.__init__(prefer_result_content)
CLI-->>StreamResp: stream messages with result
StreamResp->>StreamResp: convert_stream()
else non-streaming
API->>NonStreamResp: _collect_non_streaming_response(..., prefer_result_content=json_schema is not None)
NonStreamResp->>NonStreamResp: create_non_streaming_response(..., prefer_result_content)
NonStreamResp->>NonStreamResp: _extract_result_content(messages)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Summary by QodoAdd OpenAI json_schema response_format passthrough to Claude Code CLI
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
JSONSchemaSpec.strictfield is accepted but never used downstream; consider either wiring this through to CLI invocation/validation or removing it to avoid implying behavior that doesn’t exist. - The
prefer_result_contentflag currently switches content based solely onjson_schema is not None; if you anticipate other future uses ofresponse_format, you may want a more explicit check (e.g.,response_format.type == 'json_schema') to avoid accidentally changing behavior for non-schema formats.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `JSONSchemaSpec.strict` field is accepted but never used downstream; consider either wiring this through to CLI invocation/validation or removing it to avoid implying behavior that doesn’t exist.
- The `prefer_result_content` flag currently switches content based solely on `json_schema is not None`; if you anticipate other future uses of `response_format`, you may want a more explicit check (e.g., `response_format.type == 'json_schema'`) to avoid accidentally changing behavior for non-schema formats.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Code Review by Qodo
1.
|
Summary by Sourcery
Add support for OpenAI-compatible json_schema response_format by wiring JSON Schema through to the Claude CLI, and preferring validated result content in both streaming and non-streaming responses when a schema is provided.
New Features:
Enhancements: