-
Notifications
You must be signed in to change notification settings - Fork 20
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
54 unified response #55
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #55 +/- ##
===========================================
+ Coverage 67.52% 69.56% +2.04%
===========================================
Files 8 8
Lines 234 276 +42
===========================================
+ Hits 158 192 +34
- Misses 65 71 +6
- Partials 11 13 +2 ☔ View full report in Codecov by Sentry. |
|
||
var tokenCount schemas.TokenCount | ||
|
||
message := responseJSON["choices"].([]interface{})[0].(map[string]interface{})["message"].(map[string]interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkrueger12 looking at this code I feel like it's worth defining OpenAI Chat Response schema, map the response into it and then remap into the unified chat response schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roma-glushko I can do that. What advantage does it provide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkrueger12 That would make the implementation more readable at very least and it would give an understanding what the actual provider response might look like, what information it contains in a declarative way 👀
In this specific case, expression like responseJSON["choices"].([]interface{})[0].(map[string]interface{})
means that you are sure that the response has the choices
key where you also are sure there is at least one item e.g. [0]
. But is this always a case? Because if not I think this code will fail with an exception trying to access that info but in fact getting nil
.
If you had a validation via the defined OpenAI chat response, you would ensure that the response has all needed fields which would simply the code here.
Something like that.
|
||
response = schemas.UnifiedChatResponse{ | ||
ID: responseJSON["id"].(string), | ||
Created: float64(time.Now().Unix()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it in UTC timezone?
Router string `json:"router,omitempty"` | ||
Model string `json:"model,omitempty"` | ||
Cached bool `json:"cached,omitempty"` | ||
ProviderResponse ProviderResponse `json:"provider_response,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think ProviderResponse
-> ModelResponse
would be a good idea?
Updated the Unified schema per the GEP
Updated the doChatRequest func to marshal openai response into the unified response
Tested