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

Problems when using toolcalls in streaming #164

Open
yp05327 opened this issue Jan 13, 2025 · 0 comments
Open

Problems when using toolcalls in streaming #164

yp05327 opened this issue Jan 13, 2025 · 0 comments

Comments

@yp05327
Copy link

yp05327 commented Jan 13, 2025

  1. The return of acc.JustFinishedToolCall() - FinishedChatCompletionToolCall does not contain toolCallID, which is is required for openai.ToolMessage, so users need to record it by themselves.
  2. We should append the origin tool call Message to the message list used in the API call.
    For non-streaming, you can simply append chat.choices[0].message like:
    https://github.com/openai/openai-[go/blob/952d231c9d5fce675262a6a639a99a62249d4a7f/examples/chat-completion-tool-calling/main.go#L62](https://www.golinks.io/blob/952d231c9d5fce675262a6a639a99a62249d4a7f/examples/chat-completion-tool-calling/main.go#L62?trackSource=github)
    For streaming, it seems that there's not implements about it, maybe something like openai.ToolCallsMessage? Or, simply use FinishedChatCompletionToolCall as the Message?
    Also, I could not find any examples about it. I only found this:
    https://github.com/openai/openai-[go/blob/952d231c9d5fce675262a6a639a99a62249d4a7f/examples/chat-completion-accumulating/main.go#L65-L68](https://www.golinks.io/blob/952d231c9d5fce675262a6a639a99a62249d4a7f/examples/chat-completion-accumulating/main.go#L65-L68?trackSource=github)
    If you don't append the origin tool call Message with only one openai.ToolMessage, you will get this error:

Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'tool_calls'.

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

1 participant