Skip to content

Commit

Permalink
Stream support in createRun and submitToolOutputs
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed May 20, 2024
1 parent b7a70b3 commit 63c8b9d
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/OpenAi.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,18 @@ public function listMessageFiles($threadId, $messageId, $query = [])
* @param array $data
* @return bool|string
*/
public function createRun($threadId, $data)
public function createRun($threadId, $data, $stream = null)
{
if (array_key_exists('stream', $data) && $data['stream']) {
if ($stream == null) {
throw new Exception(
'Please provide a stream function. Check https://github.com/orhanerday/open-ai#stream-example for an example.'
);
}

$this->stream_method = $stream;
}

$this->addAssistantsBetaHeader();
$url = Url::threadsUrl() . '/' . $threadId . '/runs';
$this->baseUrl($url);
Expand Down Expand Up @@ -770,8 +780,18 @@ public function listRuns($threadId, $query = [])
* @param array $outputs
* @return bool|string
*/
public function submitToolOutputs($threadId, $runId, $outputs)
public function submitToolOutputs($threadId, $runId, $outputs, $stream = null)
{
if (array_key_exists('stream', $outputs) && $outputs['stream']) {
if ($stream == null) {
throw new Exception(
'Please provide a stream function. Check https://github.com/orhanerday/open-ai#stream-example for an example.'
);
}

$this->stream_method = $stream;
}

$this->addAssistantsBetaHeader();
$url = Url::threadsUrl() . '/' . $threadId . '/runs/' . $runId . '/submit_tool_outputs';
$this->baseUrl($url);
Expand Down

0 comments on commit 63c8b9d

Please sign in to comment.