fix: adds created timestamp for openai text completions - #5407
Conversation
📝 WalkthroughWalkthroughText completion responses now expose optional creation timestamps, with OpenAI and Replicate streaming paths preserving timestamps through emitted chunks and schema conversions. ChangesText completion timestamp propagation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "fix: adds created timestamp for openai t..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@core/schemas/textcompletions.go`:
- Line 70: Update the created field in the text-completion response schema to
remove omitempty so the required Unix timestamp is always serialized, preserving
the existing json field name and type.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d807a1df-2734-4f47-b936-30ed1871da03
📒 Files selected for processing (1)
core/schemas/textcompletions.go
5ce7f0b to
222cb4f
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
core/providers/openai/openai.go (1)
697-715: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCapture
Createdbefore skipping empty-choice chunks.The handler supports usage-only chunks, but it skips every response with no choices before the new capture block. If such a chunk carries the only non-zero
Createdvalue, the final chunk omits the timestamp. Move the capture above the empty-choice check and remove the duplicate block.Proposed fix
+ if response.Created != 0 && created == 0 { + created = response.Created + } + // Skip empty responses or responses without choices if len(response.Choices) == 0 { continue } - - if response.Created != 0 && created == 0 { - created = response.Created - }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/providers/openai/openai.go` around lines 697 - 715, Move the response.Created capture logic in the streaming handler before the len(response.Choices) == 0 early-continue, so usage-only chunks can populate created; remove the later duplicate capture while leaving messageID and choice/finish-reason handling unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@core/providers/openai/openai.go`:
- Around line 697-715: Move the response.Created capture logic in the streaming
handler before the len(response.Choices) == 0 early-continue, so usage-only
chunks can populate created; remove the later duplicate capture while leaving
messageID and choice/finish-reason handling unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 33b09e60-5b89-4daf-860a-0b40e5bee824
📒 Files selected for processing (6)
core/providers/openai/openai.gocore/providers/replicate/replicate.gocore/providers/replicate/text.gocore/providers/utils/utils.gocore/schemas/mux.gocore/schemas/textcompletions.go
🚧 Files skipped from review as they are similar to previous changes (1)
- core/schemas/textcompletions.go
e288ecc to
0fa6e8a
Compare
222cb4f to
0ca30c5
Compare
Merge activity
|
The base branch was changed.
* chore: fix migration tests * framework test fixes (#5421) * chore: adds docs for azure model router (#5175) ## Summary Adds a dedicated documentation page for the Azure Model Router provider, explaining how Bifrost automatically falls back to Chat Completions when a model-router deployment is targeted via the Responses API. ## Changes - Added `docs/providers/supported-providers/azure-model-router.mdx` documenting the Azure model-router routing behavior, supported operations, a Mermaid flowchart illustrating the fallback logic, usage examples (REST and Go SDK), and known limitations. - Registered the new page in `docs/docs.json` so it appears in the navigation between the Azure and Bedrock entries. ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [x] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [x] Docs ## How to test Navigate to the Azure Model Router page in the rendered docs and verify: - The page appears in the sidebar between Azure and Bedrock. - The Mermaid flowchart renders correctly. - All code examples and notes display as expected. ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations None. This is a documentation-only change with no impact on auth, secrets, or runtime behavior. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [x] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable * fix: adds created timestamp for openai text completions (#5407) ## Summary Adds the missing `created` field to `BifrostTextCompletionResponse` to align with the OpenAI text completion response schema, and modernizes the `ExtraParams` type alias from `map[string]interface{}` to the equivalent `map[string]any`. ## Changes - Added `Created int` field with `omitempty` to `BifrostTextCompletionResponse`, representing the Unix timestamp (in seconds) of when the completion was created — this field was previously absent from the struct despite being part of the API response. - Replaced `map[string]interface{}` with `map[string]any` in `TextCompletionParameters.ExtraParams` to use the modern Go type alias. ## Type of change - [ ] Bug fix - [ ] Feature - [x] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go version go test ./... ``` Verify that text completion responses now include the `created` timestamp field when it is non-zero. ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations None. ## Checklist - [x] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [x] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [x] I verified the CI pipeline passes locally if applicable --------- Co-authored-by: Samyabrata Maji <116789799+sammaji@users.noreply.github.com> Co-authored-by: Samyabrata Maji <samyabratamaji334@gmail.com>
## Summary
Adds the missing `created` field to `BifrostTextCompletionResponse` to align with the OpenAI text completion response schema, and modernizes the `ExtraParams` type alias from `map[string]interface{}` to the equivalent `map[string]any`.
## Changes
- Added `Created int` field with `omitempty` to `BifrostTextCompletionResponse`, representing the Unix timestamp (in seconds) of when the completion was created — this field was previously absent from the struct despite being part of the API response.
- Replaced `map[string]interface{}` with `map[string]any` in `TextCompletionParameters.ExtraParams` to use the modern Go type alias.
## Type of change
- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI
## Affected areas
- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
```sh
go version
go test ./...
```
Verify that text completion responses now include the `created` timestamp field when it is non-zero.
## Screenshots/Recordings
N/A
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
N/A
## Security considerations
None.
## Checklist
- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
* chore: fix migration tests * framework test fixes (maximhq#5421) * chore: adds docs for azure model router (maximhq#5175) ## Summary Adds a dedicated documentation page for the Azure Model Router provider, explaining how Bifrost automatically falls back to Chat Completions when a model-router deployment is targeted via the Responses API. ## Changes - Added `docs/providers/supported-providers/azure-model-router.mdx` documenting the Azure model-router routing behavior, supported operations, a Mermaid flowchart illustrating the fallback logic, usage examples (REST and Go SDK), and known limitations. - Registered the new page in `docs/docs.json` so it appears in the navigation between the Azure and Bedrock entries. ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [x] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [x] Docs ## How to test Navigate to the Azure Model Router page in the rendered docs and verify: - The page appears in the sidebar between Azure and Bedrock. - The Mermaid flowchart renders correctly. - All code examples and notes display as expected. ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations None. This is a documentation-only change with no impact on auth, secrets, or runtime behavior. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [x] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable * fix: adds created timestamp for openai text completions (maximhq#5407) ## Summary Adds the missing `created` field to `BifrostTextCompletionResponse` to align with the OpenAI text completion response schema, and modernizes the `ExtraParams` type alias from `map[string]interface{}` to the equivalent `map[string]any`. ## Changes - Added `Created int` field with `omitempty` to `BifrostTextCompletionResponse`, representing the Unix timestamp (in seconds) of when the completion was created — this field was previously absent from the struct despite being part of the API response. - Replaced `map[string]interface{}` with `map[string]any` in `TextCompletionParameters.ExtraParams` to use the modern Go type alias. ## Type of change - [ ] Bug fix - [ ] Feature - [x] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go version go test ./... ``` Verify that text completion responses now include the `created` timestamp field when it is non-zero. ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations None. ## Checklist - [x] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [x] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [x] I verified the CI pipeline passes locally if applicable --------- Co-authored-by: Samyabrata Maji <116789799+sammaji@users.noreply.github.com> Co-authored-by: Samyabrata Maji <samyabratamaji334@gmail.com>
## Summary
Adds the missing `created` field to `BifrostTextCompletionResponse` to align with the OpenAI text completion response schema, and modernizes the `ExtraParams` type alias from `map[string]interface{}` to the equivalent `map[string]any`.
## Changes
- Added `Created int` field with `omitempty` to `BifrostTextCompletionResponse`, representing the Unix timestamp (in seconds) of when the completion was created — this field was previously absent from the struct despite being part of the API response.
- Replaced `map[string]interface{}` with `map[string]any` in `TextCompletionParameters.ExtraParams` to use the modern Go type alias.
## Type of change
- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI
## Affected areas
- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
```sh
go version
go test ./...
```
Verify that text completion responses now include the `created` timestamp field when it is non-zero.
## Screenshots/Recordings
N/A
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
N/A
## Security considerations
None.
## Checklist
- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
* chore: fix migration tests * framework test fixes (maximhq#5421) * chore: adds docs for azure model router (maximhq#5175) ## Summary Adds a dedicated documentation page for the Azure Model Router provider, explaining how Bifrost automatically falls back to Chat Completions when a model-router deployment is targeted via the Responses API. ## Changes - Added `docs/providers/supported-providers/azure-model-router.mdx` documenting the Azure model-router routing behavior, supported operations, a Mermaid flowchart illustrating the fallback logic, usage examples (REST and Go SDK), and known limitations. - Registered the new page in `docs/docs.json` so it appears in the navigation between the Azure and Bedrock entries. ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [x] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [x] Docs ## How to test Navigate to the Azure Model Router page in the rendered docs and verify: - The page appears in the sidebar between Azure and Bedrock. - The Mermaid flowchart renders correctly. - All code examples and notes display as expected. ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations None. This is a documentation-only change with no impact on auth, secrets, or runtime behavior. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [x] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable * fix: adds created timestamp for openai text completions (maximhq#5407) ## Summary Adds the missing `created` field to `BifrostTextCompletionResponse` to align with the OpenAI text completion response schema, and modernizes the `ExtraParams` type alias from `map[string]interface{}` to the equivalent `map[string]any`. ## Changes - Added `Created int` field with `omitempty` to `BifrostTextCompletionResponse`, representing the Unix timestamp (in seconds) of when the completion was created — this field was previously absent from the struct despite being part of the API response. - Replaced `map[string]interface{}` with `map[string]any` in `TextCompletionParameters.ExtraParams` to use the modern Go type alias. ## Type of change - [ ] Bug fix - [ ] Feature - [x] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go version go test ./... ``` Verify that text completion responses now include the `created` timestamp field when it is non-zero. ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations None. ## Checklist - [x] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [x] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [x] I verified the CI pipeline passes locally if applicable --------- Co-authored-by: Samyabrata Maji <116789799+sammaji@users.noreply.github.com> Co-authored-by: Samyabrata Maji <samyabratamaji334@gmail.com>

Summary
Adds the missing
createdfield toBifrostTextCompletionResponseto align with the OpenAI text completion response schema, and modernizes theExtraParamstype alias frommap[string]interface{}to the equivalentmap[string]any.Changes
Created intfield withomitemptytoBifrostTextCompletionResponse, representing the Unix timestamp (in seconds) of when the completion was created — this field was previously absent from the struct despite being part of the API response.map[string]interface{}withmap[string]anyinTextCompletionParameters.ExtraParamsto use the modern Go type alias.Type of change
Affected areas
How to test
go version go test ./...Verify that text completion responses now include the
createdtimestamp field when it is non-zero.Screenshots/Recordings
N/A
Breaking changes
Related issues
N/A
Security considerations
None.
Checklist
docs/contributing/README.mdand followed the guidelines