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

Tool calls in streamed responses #93

Open
arnaudgoulpeau opened this issue Apr 2, 2024 · 1 comment
Open

Tool calls in streamed responses #93

arnaudgoulpeau opened this issue Apr 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@arnaudgoulpeau
Copy link

Hi !

I tried to use the OpenAIChat::createStreamedResponse with a function.

The finishReason is not function_call but tool_calls

It is not the only issue I faced.

Since it is a stream, when hitting the finishReason="tool_class", the array $toolsCalled is empty.

Here is the cinematic of $partialResponse->choices[0]->delta->toolCalls (note that $toolsCalled = []; for each piece of stream)

array:1 [
  0 => OpenAI\Responses\Chat\CreateStreamedResponseToolCall^ {#202
    +id: "call_lzS2i19jrpRSCKftKDLoRa2G"
    +type: "function"
    +function: OpenAI\Responses\Chat\CreateStreamedResponseToolCallFunction^ {#178
      +name: "sendMail"
      +arguments: ""
    }
  }
]
array:1 [
  0 => OpenAI\Responses\Chat\CreateStreamedResponseToolCall^ {#86
    +id: null
    +type: null
    +function: OpenAI\Responses\Chat\CreateStreamedResponseToolCallFunction^ {#400
      +name: null
      +arguments: "{\n"
    }
  }
]

...

array:1 [
  0 => OpenAI\Responses\Chat\CreateStreamedResponseToolCall^ {#414
    +id: null
    +type: null
    +function: OpenAI\Responses\Chat\CreateStreamedResponseToolCallFunction^ {#413
      +name: null
      +arguments: "}"
    }
  }
]
[]

Note the empty array

I honnestly don't know how to "merge" the buidling $toolsCalled for each piece of stream.

@MaximeThoonsen
Copy link
Contributor

MaximeThoonsen commented Apr 10, 2024

Hey @arnaudgoulpeau,
thanks for having spotted this. I'll have a look at it when I have a bit of time.

Can you write me the code you used to get this so I can use it as a test?

@MaximeThoonsen MaximeThoonsen added the bug Something isn't working label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants