Skip to content

fix(chat): return a Unix timestamp in the OpenAI-compatible 'created' field - #7611

Open
pcbeingused333 wants to merge 1 commit into
1Panel-dev:v2from
pcbeingused333:c0556-created-timestamp
Open

pcbeingused333 wants to merge 1 commit into
1Panel-dev:v2from
pcbeingused333:c0556-created-timestamp

Conversation

@pcbeingused333

Copy link
Copy Markdown

What this PR does / why we need it?

OpenaiToResponse set the created field of the OpenAI-compatible responses (blocking and streaming) to timezone.now().second, which is the seconds component of the clock (0–59), not a timestamp. Clients of the OpenAI-compatible API therefore received created values like 7 or 42 instead of the Unix time the OpenAI API specifies. No linked issue.

Summary of your change

  • apps/common/handle/impl/response/openai_to_response.py: use int(timezone.now().timestamp()) for created in both the blocking response and the stream chunk.
  • apps/common/tests_openai_to_response.py (new): freezes the clock and checks created in both paths; both tests fail before the change and pass after it.

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed. (No docs impact.)

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

… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant