Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Classes/Provider/OpenAiProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function chatCompletion(array $messages, array $options = []): Completion
'model' => $model,
'messages' => $messages,
'temperature' => $this->getFloat($options, 'temperature', 0.7),
'max_tokens' => $this->getInt($options, 'max_tokens', 4096),
'max_completion_tokens' => $this->getInt($options, 'max_tokens', 4096),
];

if (isset($options['top_p'])) {
Expand Down Expand Up @@ -150,7 +150,7 @@ public function chatCompletionWithTools(array $messages, array $tools, array $op
'messages' => $messages,
'tools' => $tools,
'temperature' => $this->getFloat($options, 'temperature', 0.7),
'max_tokens' => $this->getInt($options, 'max_tokens', 4096),
'max_completion_tokens' => $this->getInt($options, 'max_tokens', 4096),
];

if (isset($options['tool_choice'])) {
Expand Down Expand Up @@ -274,7 +274,7 @@ public function analyzeImage(array $content, array $options = []): VisionRespons
$payload = [
'model' => $model,
'messages' => $messages,
'max_tokens' => $this->getInt($options, 'max_tokens', 4096),
'max_completion_tokens' => $this->getInt($options, 'max_tokens', 4096),
];

$response = $this->sendRequest('chat/completions', $payload);
Expand Down Expand Up @@ -325,7 +325,7 @@ public function streamChatCompletion(array $messages, array $options = []): Gene
'model' => $this->getString($options, 'model', $this->getDefaultModel()),
'messages' => $messages,
'temperature' => $this->getFloat($options, 'temperature', 0.7),
'max_tokens' => $this->getInt($options, 'max_tokens', 4096),
'max_completion_tokens' => $this->getInt($options, 'max_tokens', 4096),
'stream' => true,
];

Expand Down
4 changes: 2 additions & 2 deletions Tests/E2E/ChatCompletionWorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ public function chatWithOptionsWorkflow(): void
$requestBody = json_decode((string)$clientSetup['requests'][0]->getBody(), true);
self::assertIsArray($requestBody);
self::assertArrayHasKey('temperature', $requestBody);
self::assertArrayHasKey('max_tokens', $requestBody);
self::assertArrayHasKey('max_completion_tokens', $requestBody);
self::assertEquals(0.1, $requestBody['temperature']);
self::assertEquals(500, $requestBody['max_tokens']);
self::assertEquals(500, $requestBody['max_completion_tokens']);
}

#[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function chatWithOptionsPassesThemToProvider(): void
self::assertIsArray($body);

self::assertEquals(0.5, $body['temperature']);
Comment thread
CybotTM marked this conversation as resolved.
self::assertEquals(100, $body['max_tokens']);
self::assertEquals(100, $body['max_completion_tokens']);
}

#[Test]
Expand Down
Loading