-
Notifications
You must be signed in to change notification settings - Fork 1
fix: empty response #23
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -469,6 +469,12 @@ class _ProxyIsolateHost { | |||||||||||||||||||
| details: _requestContextPayload(prompt: resolvedPrompt), | ||||||||||||||||||||
| ); | ||||||||||||||||||||
| final payload = await _executeNonStreamRequest(resolvedPrompt, retryTracker: retryTracker); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| final candidates = payload['candidates'] as List?; | ||||||||||||||||||||
| if (candidates != null && candidates.isEmpty) { | ||||||||||||||||||||
| return _errorResponse(502, 'bad_gateway', 'Upstream API returned empty candidates'); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| await _logTrace( | ||||||||||||||||||||
| category: 'chat.completions', | ||||||||||||||||||||
| route: route, | ||||||||||||||||||||
|
|
@@ -664,6 +670,12 @@ class _ProxyIsolateHost { | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| final payload = await _executeNonStreamRequest(resolvedPrompt, retryTracker: retryTracker); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| final candidates = payload['candidates'] as List?; | ||||||||||||||||||||
| if (candidates != null && candidates.isEmpty) { | ||||||||||||||||||||
| return _errorResponse(502, 'bad_gateway', 'Upstream API returned empty candidates'); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+674
to
+677
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation of the added lines is inconsistent with the rest of the file (which uses 2 spaces). Additionally, the check for
Suggested change
References
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| await _logResponsePreview( | ||||||||||||||||||||
| category: 'responses', | ||||||||||||||||||||
| route: route, | ||||||||||||||||||||
|
|
||||||||||||||||||||
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.
The indentation of the added lines is inconsistent with the rest of the file (which uses 2 spaces). Additionally, the check for
candidatesis incomplete as it doesn't account for potential nesting under aresponsekey, which is handled elsewhere in the codebase (e.g., inOpenAiResponseMapper). Usingis Listinstead of a cast is also safer to avoid potentialTypeErrorif the upstream returns an unexpected type. According to the Dart style guide, indentation should be 2 spaces.References