diff --git a/Classes/Provider/OpenAiProvider.php b/Classes/Provider/OpenAiProvider.php index 9124dc70b..21727d62a 100644 --- a/Classes/Provider/OpenAiProvider.php +++ b/Classes/Provider/OpenAiProvider.php @@ -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'])) { @@ -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'])) { @@ -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); @@ -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, ]; diff --git a/Tests/E2E/ChatCompletionWorkflowTest.php b/Tests/E2E/ChatCompletionWorkflowTest.php index be4c00461..5df965a67 100644 --- a/Tests/E2E/ChatCompletionWorkflowTest.php +++ b/Tests/E2E/ChatCompletionWorkflowTest.php @@ -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] diff --git a/Tests/Integration/Service/LlmServiceManagerIntegrationTest.php b/Tests/Integration/Service/LlmServiceManagerIntegrationTest.php index d585a08aa..462906e18 100644 --- a/Tests/Integration/Service/LlmServiceManagerIntegrationTest.php +++ b/Tests/Integration/Service/LlmServiceManagerIntegrationTest.php @@ -300,7 +300,7 @@ public function chatWithOptionsPassesThemToProvider(): void self::assertIsArray($body); self::assertEquals(0.5, $body['temperature']); - self::assertEquals(100, $body['max_tokens']); + self::assertEquals(100, $body['max_completion_tokens']); } #[Test]