Repository navigation
fix(chat): return a Unix timestamp in the OpenAI-compatible 'created' field - #7611
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
… field created was set to timezone.now().second, i.e. the seconds field of the clock (0-59), instead of the Unix timestamp the OpenAI API specifies. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
OpenaiToResponseset thecreatedfield of the OpenAI-compatible responses (blocking and streaming) totimezone.now().second, which is the seconds component of the clock (0–59), not a timestamp. Clients of the OpenAI-compatible API therefore receivedcreatedvalues like7or42instead of the Unix time the OpenAI API specifies. No linked issue.Summary of your change
apps/common/handle/impl/response/openai_to_response.py: useint(timezone.now().timestamp())forcreatedin both the blocking response and the stream chunk.apps/common/tests_openai_to_response.py(new): freezes the clock and checkscreatedin both paths; both tests fail before the change and pass after it.Please indicate you've done the following:
This PR was prepared with the help of an AI assistant (Claude Code), and the author is responsible for the change.
🤖 Generated with Claude Code