Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

validate OpenAI responses#2226

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
samuelcolvin wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromcheck-openai-reponse-type

Conversation

samuelcolvin
Copy link
Member

@samuelcolvinsamuelcolvin commentedJul 17, 2025
edited
Loading

@DouweM@Kludex I think there were some issues about this, can you remember?

maybefixes#527?

Although the OpenAI SDK claims to return a Pydantic model (ChatCompletion) from the chat completions endpoint:

  • it hasn't actually performed validation (presumably they're creating the model withmodel_construct or something?!)
  • if the endpoint returns plain text, the return type is a string

Thus we validate it fully here.

@github-actionsGitHub Actions
Copy link

github-actionsbot commentedJul 17, 2025
edited
Loading

Docs Preview

commit:e1bc138
Preview URL:https://904ab5a1-pydantic-ai-previews.pydantic.workers.dev

Copy link
Member

@KludexKludex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How are you generating those tests? Manually? 🤔


async def test_valid_response(env: TestEnv, allow_model_requests: None):
"""VCR recording is of a valid response."""
env.set('OPENAI_API_KEY', 'foobar')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You should use theopenai_api_key fixture here.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@KludexKludexKludex left review comments

Assignees

@samuelcolvinsamuelcolvin

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[BUG] Error responses are not handled correctly for google openai/openrouter
3 participants
@samuelcolvin@Kludex@DouweM

[8]ページ先頭

©2009-2025 Movatter.jp