Skip to content
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

Wrong types in StreamedChatResponseV2 for Tool Calls #95

Open
adrianliechti opened this issue Dec 11, 2024 · 2 comments
Open

Wrong types in StreamedChatResponseV2 for Tool Calls #95

adrianliechti opened this issue Dec 11, 2024 · 2 comments

Comments

@adrianliechti
Copy link

adrianliechti commented Dec 11, 2024

After a short debugging, I believe this struct needs V2 structs for at least ToolCallStart & ToolCallDelta.
see also json field: tool_call vs tool_calls

type StreamedChatResponseV2 struct {
	Type          string
	MessageStart  *ChatMessageStartEvent
	ContentStart  *ChatContentStartEvent
	ContentDelta  *ChatContentDeltaEvent
	ContentEnd    *ChatContentEndEvent
	ToolPlanDelta *ChatToolPlanDeltaEvent
	ToolCallStart *ChatToolCallStartEvent // <-- 
	ToolCallDelta *ChatToolCallDeltaEvent // <--
	ToolCallEnd   *ChatToolCallEndEvent // <--
	CitationStart *CitationStartEvent
	CitationEnd   *CitationEndEvent
	MessageEnd    *ChatMessageEndEvent
}
@adrianliechti adrianliechti changed the title Tool Calls not working in V2 Chat Streaming due wrong Json Structs Wrong types in StreamedChatResponseV2 for Tool Calls Dec 11, 2024
@adrianliechti
Copy link
Author

adrianliechti commented Dec 11, 2024

workaround:

parse the event delta as temporary message struct

var data struct {
  Message struct {
     ToolCalls *v2.ToolCallV2 `json:"tool_calls"`
  } `json:"message"`
}

json.Unmarshal([]byte(resp.ToolCallDelta.Delta.String()), &data)

@billytrend-cohere
Copy link
Collaborator

Investigating this thanks, @adrianliechti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants