-
Notifications
You must be signed in to change notification settings - Fork 672
fix: handle mixed text and function call responses in shim #437
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -913,8 +913,12 @@ func candidateToShimCandidate(iterator gollm.ChatResponseIterator) (gollm.ChatRe | |||||
| if text, ok := part.AsText(); ok { | ||||||
| buffer += text | ||||||
| klog.Infof("text is %q", text) | ||||||
| } else { | ||||||
| yield(nil, fmt.Errorf("no text part found in candidate")) | ||||||
| } else if calls, ok := part.AsFunctionCalls(); ok && len(calls) > 0 { | ||||||
| // If we encounter function calls, we should not use the shim | ||||||
| // Instead, pass through the original response | ||||||
| klog.Infof("Warning: there are non-text parts FunctionCall in the response, returning concatenation of all text parts.") | ||||||
|
||||||
| klog.Infof("Warning: there are non-text parts FunctionCall in the response, returning concatenation of all text parts.") | |
| klog.Infof("Warning: there are non-text parts (function calls) in the response, returning concatenation of all text parts.") |
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.
If I understand correctly,
in case of tool-use-shim, the API does not return toolCalls, so we accumulate all the text and then parse the text to convert into toolcall. So the change here will simply return text response to the layer above.
Copilot
AI
Aug 1, 2025
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 accumulated text buffer is discarded when function calls are detected. Consider whether any accumulated text should be preserved or if this is the intended behavior.
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 log message is misleading. It states 'returning concatenation of all text parts' but the code actually returns the original response without concatenation.