-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(anthropic): use anthropic sdk to transform malformed response schemas to anthropic format #2988
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
…emas to anthropic format
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile OverviewGreptile SummaryUpgraded Key Changes:
Benefits:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant AnthropicProvider
participant SDK as @anthropic-ai/sdk
participant Transform as transformJSONSchema
participant API as Anthropic API
Client->>AnthropicProvider: executeRequest(request)
alt request.responseFormat exists
AnthropicProvider->>AnthropicProvider: Check if native structured outputs supported
alt useNativeStructuredOutputs = true
Note over AnthropicProvider: Extract schema from request.responseFormat
AnthropicProvider->>Transform: transformJSONSchema(schema)
Note over Transform: SDK transforms schema:<br/>- Adds additionalProperties: false<br/>- Removes unsupported constraints<br/>- Filters string formats
Transform-->>AnthropicProvider: transformedSchema
AnthropicProvider->>AnthropicProvider: Set payload.output_format = {<br/> type: 'json_schema',<br/> schema: transformedSchema<br/>}
else useNativeStructuredOutputs = false
AnthropicProvider->>AnthropicProvider: generateSchemaInstructions(schema)
AnthropicProvider->>AnthropicProvider: Append schema to system prompt
end
end
AnthropicProvider->>SDK: messages.create(payload)
SDK->>API: HTTP Request with transformed schema
API-->>SDK: Response
SDK-->>AnthropicProvider: Response
AnthropicProvider-->>Client: ProviderResponse | StreamingExecution
|
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.
2 files reviewed, 2 comments
|
@greptile |
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.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
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.
2 files reviewed, 2 comments
|
@greptile |
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.
No files reviewed, no comments
Summary
Type of Change
Testing
Tested manually
Checklist