enhancement: serialisation optimisations#194
Conversation
Summary by CodeRabbit
No changes to user-facing features or APIs. WalkthroughThe changes replace all uses of the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Provider (OpenAI/Vertex)
participant Sonic (JSON)
participant Schemas
Client->>Provider (OpenAI/Vertex): Send request
Provider (OpenAI/Vertex)->>Sonic (JSON): Marshal/Unmarshal request/response
Sonic (JSON)-->>Provider (OpenAI/Vertex): Serialized/Deserialized data
Provider (OpenAI/Vertex)->>Schemas: Use BifrostResponse/BifrostError
Schemas-->>Provider (OpenAI/Vertex): Structured data
Provider (OpenAI/Vertex)-->>Client: Return response or error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
7ef1f01 to
51d3bd0
Compare
51d3bd0 to
16f5db0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
core/providers/utils.go (1)
311-349: Simplify concurrent unmarshaling logicThe current implementation has unnecessary complexity with commented-out code and unused variables. The concurrent goroutine pattern is no longer needed since raw response unmarshaling has been removed.
Apply this diff to simplify the function:
func handleProviderResponse[T any](responseBody []byte, response *T) (interface{}, *schemas.BifrostError) { - // var rawResponse interface{} - - var wg sync.WaitGroup - var structuredErr, rawErr error - - wg.Add(2) - go func() { - defer wg.Done() - structuredErr = sonic.Unmarshal(responseBody, response) - }() - go func() { - defer wg.Done() - // rawErr = sonic.Unmarshal(responseBody, &rawResponse) - }() - wg.Wait() - - if structuredErr != nil { + if err := sonic.Unmarshal(responseBody, response); err != nil { return nil, &schemas.BifrostError{ IsBifrostError: true, Error: schemas.ErrorField{ Message: schemas.ErrProviderDecodeStructured, - Error: structuredErr, + Error: err, }, } } - if rawErr != nil { - return nil, &schemas.BifrostError{ - IsBifrostError: true, - Error: schemas.ErrorField{ - Message: schemas.ErrProviderDecodeRaw, - Error: rawErr, - }, - } - } - return nil, nil }
Merge activity
|

No description provided.