diff --git a/src/Providers/DeepSeek/Handlers/Structured.php b/src/Providers/DeepSeek/Handlers/Structured.php index a71bce93b..76c4f76de 100644 --- a/src/Providers/DeepSeek/Handlers/Structured.php +++ b/src/Providers/DeepSeek/Handlers/Structured.php @@ -57,7 +57,7 @@ protected function sendRequest(Request $request): array [ 'model' => $request->model(), 'messages' => (new MessageMap($request->messages(), $request->systemPrompts()))(), - 'max_completion_tokens' => $request->maxTokens(), + 'max_tokens' => $request->maxTokens(), ], Arr::whereNotNull([ 'temperature' => $request->temperature(), diff --git a/tests/Providers/DeepSeek/StructuredTest.php b/tests/Providers/DeepSeek/StructuredTest.php index 9f23a2c3c..54a540ebd 100644 --- a/tests/Providers/DeepSeek/StructuredTest.php +++ b/tests/Providers/DeepSeek/StructuredTest.php @@ -76,3 +76,21 @@ return true; }); }); + +it('sends the max tokens as max_tokens, the parameter DeepSeek reads', function (): void { + FixtureResponse::fakeResponseSequence('v1/chat/completions', 'deepseek/structured'); + + Prism::structured() + ->using(Provider::DeepSeek, 'deepseek-chat') + ->withSchema(new ObjectSchema('output', 'the output object', [new StringSchema('weather', 'The weather forecast')], ['weather'])) + ->withPrompt('What is the weather?') + ->withMaxTokens(100) + ->asStructured(); + + Http::assertSent(function (Request $request): bool { + expect($request->data()['max_tokens'])->toBe(100); + expect($request->data())->not->toHaveKey('max_completion_tokens'); + + return true; + }); +});