-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat:Add public schemas; update OutputItem.content; allow reasoning_text #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds new public schemas (OutputMessageContent, ReasoningTextContent, Summary), updates OutputItem.content to use OutputMessageContent, expands allowed output content types to include reasoning_text, wraps an output field in anyOf, and makes minor documentation and example ID updates in src/libs/tryAGI.OpenAI/openapi.yaml. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant API as OpenAI-compatible API
participant Model
Client->>API: Request completion/run
API->>Model: Invoke model with inputs
Model-->>API: Output content items
note over Model,API: Output variants:<br/>- OutputTextContent<br/>- RefusalContent<br/>- ReasoningTextContent<br/>- Summary (summary_text)
API-->>Client: Response with OutputItem.content[] as OutputMessageContent anyOf
rect rgba(200,230,255,0.25)
note right of API: Changed: OutputItem.content now uses<br/>OutputMessageContent discriminator.
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (4)
src/libs/tryAGI.OpenAI/openapi.yaml (4)
10441-10441: Consider adding a pattern/format for conversation IDs.Optional: add a pattern like '^[a-z]+_[A-Za-z0-9]+' or a shared schema to enforce ID shape.
15689-15693: anyOf with a single branch adds complexity without value.If no other branch is intended yet, inline the string schema instead of wrapping it in anyOf. If you plan multiple shapes, keep anyOf but add all intended variants now (e.g., also allow null/object).
24771-24788: Add minimal constraints for text fields.Optional: enforce non-empty reasoning text via minLength: 1.
properties: text: type: string description: The reasoning text from the model. + minLength: 1
28312-28329: Avoid duplicating Summary vs SummaryTextContent; reuse one schema.These shapes appear identical; duplication hurts codegen and docs. Prefer a single schema and reference it where needed.
Apply either approach:
- Replace uses of Summary with SummaryTextContent and remove Summary, or
- Make Summary a $ref alias to SummaryTextContent.
Example (aliasing Summary to SummaryTextContent):
- Summary: - title: Summary text - required: - - type - - text - type: object - properties: - text: - type: string - description: A summary of the reasoning output from the model so far. - type: - enum: - - summary_text - type: string - description: The type of the object. Always `summary_text`. - default: summary_text - x-stainless-const: true - description: A summary text from the model. + Summary: + $ref: '#/components/schemas/SummaryTextContent'And at Line 24762:
- $ref: '#/components/schemas/Summary' + $ref: '#/components/schemas/SummaryTextContent'
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (28)
src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI..JsonSerializerContext.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ContentItem.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.OutputContent.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.OutputMessageContent.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ReasoningTextContentType.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ReasoningTextContentTypeNullable.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.SummaryType.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.SummaryTypeNullable.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContextTypes.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ComputerCallOutputItemParam.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ContentItem.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ConversationParam.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.FunctionCallOutputItemParam.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.OutputContent.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.OutputMessage.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.OutputMessageContent.Json.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.OutputMessageContent.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.OutputMessageContentDiscriminator.Json.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.OutputMessageContentDiscriminator.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ReasoningItem.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ReasoningTextContent.Json.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ReasoningTextContent.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.ReasoningTextContentType.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.Summary.Json.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.Summary.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.SummaryTextContent.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.SummaryTextContentType.g.csis excluded by!**/generated/**src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Models.SummaryType.g.csis excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/tryAGI.OpenAI/openapi.yaml(13 hunks)
🔇 Additional comments (7)
src/libs/tryAGI.OpenAI/openapi.yaml (7)
17765-17765: Adding ReasoningTextContent here is good—ensure it’s reachable via message unions.If reasoning content is meant to appear inside OutputItem.content, confirm OutputMessageContent’s union includes it (see comments below on duplicate defs).
18840-18840: LGTM pending union fix.Referencing OutputMessageContent from OutputItem.content aligns the model message shape.
Ensure the union above is de-duplicated so codegen resolves this ref correctly.
24743-24744: LGTM.Reasoning content array correctly references ReasoningTextContent.
24762-24763: LGTM.Reasoning summary array added as intended.
28339-28345: LGTM.Doc tweaks for SummaryTextContent look good.
9976-9976: Confirm 'cuo_' ID prefix consistency.
Single occurrence at src/libs/tryAGI.OpenAI/openapi.yaml:9976 (example: cuo_123). The spec otherwise uses prefixes like conv_, resp_, msg_, fc_, event_. Confirm cuo_ is intentional or align the example to the established prefix for this object.
18804-18810: Incorrect — no duplicate OutputMessageContent found.Single definition exists at src/libs/tryAGI.OpenAI/openapi.yaml:18866; no second definition or conflicting omission of ReasoningTextContent was observed.
Likely an incorrect or invalid review comment.
| examples: | ||
| request: | ||
| curl: "curl -X POST https://api.openai.com/v1/fine_tuning/alpha/graders/run \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"grader\": {\n \"type\": \"score_model\",\n \"name\": \"Example score model grader\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Score how close the reference answer is to the model answer. Score 1.0 if they are the same and 0.0 if they are different. Return just a floating point score\\n\\nReference answer: {{item.reference_answer}}\\n\\nModel answer: {{sample.output_text}}\"\n }\n ],\n \"model\": \"gpt-4o-2024-08-06\",\n \"sampling_params\": {\n \"temperature\": 1,\n \"top_p\": 1,\n \"seed\": 42\n }\n },\n \"item\": {\n \"reference_answer\": \"fuzzy wuzzy was a bear\"\n },\n \"model_sample\": \"fuzzy wuzzy was a bear\"\n }'\n" | ||
| curl: "curl -X POST https://api.openai.com/v1/fine_tuning/alpha/graders/run \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"grader\": {\n \"type\": \"score_model\",\n \"name\": \"Example score model grader\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Score how close the reference answer is to the model\nanswer. Score 1.0 if they are the same and 0.0 if they are different. Return just a floating point score\\n\\nReference answer: {{item.reference_answer}}\\n\\nModel answer: {{sample.output_text}}\"\n }\n ],\n \"model\": \"gpt-4o-2024-08-06\",\n \"sampling_params\": {\n \"temperature\": 1,\n \"top_p\": 1,\n \"seed\": 42\n }\n },\n \"item\": {\n \"reference_answer\": \"fuzzy wuzzy was a bear\"\n },\n \"model_sample\": \"fuzzy wuzzy was a bear\"\n }'\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
cURL example may embed an unescaped newline inside JSON.
Ensure the "content" string in the curl -d body uses escaped "\n" rather than a literal line break; otherwise the JSON becomes invalid in copy/paste contexts.
Run to sanity-check the JSON payload extracted from the example:
🏁 Script executed:
#!/bin/bash
# Extract the curl example and validate JSON bodies it contains
rg -nA2 -C0 'fine_tuning/alpha/graders/run' src/libs/tryAGI.OpenAI/openapi.yaml
# Manually copy the -d '{ ... }' snippet from the output and run:
python - <<'PY'
import json,sys,re
s=sys.stdin.read()
# Grab the JSON between the single quotes after -d
m=re.search(r"-d\s*'(\{.*\})'", s, re.S)
if not m:
print("No JSON found"); sys.exit(1)
try:
json.loads(m.group(1))
print("OK: JSON parses")
except Exception as e:
print("Invalid JSON:", e)
PYLength of output: 1017
Escape literal newline in the curl JSON example
The curl -d body in src/libs/tryAGI.OpenAI/openapi.yaml (endpoint /fine_tuning/alpha/graders/run, around line 2331) contains a literal line break inside the "content" string; replace the literal break with an escaped "\n" so the JSON parses when copied.
🤖 Prompt for AI Agents
In src/libs/tryAGI.OpenAI/openapi.yaml around line 2331, the curl -d JSON
example for the /fine_tuning/alpha/graders/run endpoint contains a literal
newline inside the "content" string; replace that literal line break with an
escaped "\\n" sequence so the JSON remains a single-line string and parses
correctly when copied into a shell command, ensuring any other internal newlines
in JSON examples are similarly escaped.
| type: 'null' | ||
| nullable: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Check OpenAPI version before using type: 'null'.
type: null is valid in OAS 3.1, not 3.0 (which uses nullable: true). Ensure the spec header is 3.1 or adjust accordingly.
🏁 Script executed:
#!/bin/bash
rg -nP '^openapi:\s*3\.\d+\.\d+' src/libs/tryAGI.OpenAI/openapi.yamlLength of output: 16
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE=src/libs/tryAGI.OpenAI/openapi.yaml
echo "OpenAPI header (file + match):"
rg -nP '^openapi:\s*3\.\d+\.\d+' "$FILE" || true
echo
echo "Matches for lines with 'type:' that mention 'null' (with 2 lines context):"
rg -nP -n -C2 '^\s*type:\s*[^#]*null' "$FILE" || true
echo
echo "Repository-wide 'type:' lines mentioning 'null' (file:line):"
rg -nP '^\s*type:\s*[^#]*null' || trueLength of output: 5055
Fix invalid use of type: 'null' — upgrade to OpenAPI 3.1 or replace with nullable: true.
openapi header is 3.0.4; OAS 3.0 does not support type: 'null' — either set the spec header to 3.1.0 or remove all type: 'null' usages and use nullable: true with an appropriate base type. File: src/libs/tryAGI.OpenAI/openapi.yaml (multiple occurrences; e.g. lines 7643, 8959, 15694).
🤖 Prompt for AI Agents
In src/libs/tryAGI.OpenAI/openapi.yaml around lines 7643, 8959, 15694 (and other
occurrences), the spec uses type: 'null' which is invalid for OpenAPI 3.0.4;
either update the openapi header to "3.1.0" if you want native null types, or
(preferred for minimal change) remove type: 'null' entries and instead declare
the property with the appropriate base type (e.g., string, integer, object) and
add nullable: true; apply this change consistently across all occurrences in the
file so the spec validates under OpenAPI 3.0.4.
Summary by CodeRabbit