-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix tool use input handling #68
base: main
Are you sure you want to change the base?
Conversation
Fixes liushuangls#67 Address the issue of missing `input` field in `tool_use` structure by removing `omitempty` and handling empty `input`. * **message.go** - Remove `omitempty` from the `Input` field in the `MessageContentToolUse` struct. - Update the `NewMessageContentToolUse` function to handle empty `Input` by setting it to an empty JSON object if nil. * **message_stream.go** - Update the `MessagesEventContentBlockStop` case to handle empty `Input` by setting it to an empty JSON object if nil. * **message_stream_test.go** - Add test cases for tools with and without parameters to ensure proper handling of the `input` field. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/liushuangls/go-anthropic/issues/67?shareId=XXXX-XXXX-XXXX-XXXX).
Thank you! Please fix the error in actions |
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.
Looks good overall, thank you for making that change.
Please just follow through with the rename of handlerMessagesStreamEmptyMessages
to handlerMessagesStreamToolUseWithoutParameters
where appropriate to make tests pass 😸
I think I would like to see an integration test too, but that's something we should add to the backlog rather than fiddle more here - I am excited to get this feature in! 🎉
} | ||
|
||
func NewMessageContentToolUse( | ||
toolUseId, name string, | ||
input json.RawMessage, | ||
) *MessageContentToolUse { | ||
if input == nil { | ||
input = json.RawMessage("{}") |
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.
nit: prefer backticks `
to a quotes "
for strings in go.
Fixes #67
Address the issue of missing
input
field intool_use
structure by removingomitempty
and handling emptyinput
.message.go
omitempty
from theInput
field in theMessageContentToolUse
struct.NewMessageContentToolUse
function to handle emptyInput
by setting it to an empty JSON object if nil.message_stream.go
MessagesEventContentBlockStop
case to handle emptyInput
by setting it to an empty JSON object if nil.message_stream_test.go
input
field.For more details, open the Copilot Workspace session.