diff --git a/docs/hub/basics/complex_extraction_claude.md b/docs/hub/basics/complex_extraction_claude.md index 18d31258..6f28f2a5 100644 --- a/docs/hub/basics/complex_extraction_claude.md +++ b/docs/hub/basics/complex_extraction_claude.md @@ -111,6 +111,7 @@ $instructor = (new Instructor)->withClient($client); echo "PROJECT EVENTS:\n\n"; $events = $instructor + ->withDebug() ->onSequenceUpdate(fn($sequence) => displayEvent($sequence->last())) ->request( messages: $report, diff --git a/examples/01_Basics/ValidationMixin/run.php b/examples/01_Basics/ValidationMixin/run.php index 925652ca..cb62f780 100644 --- a/examples/01_Basics/ValidationMixin/run.php +++ b/examples/01_Basics/ValidationMixin/run.php @@ -41,7 +41,6 @@ public function validate() : ValidationResult { } $user = (new Instructor) - ->withDebug(true, false) ->respond( messages: [['role' => 'user', 'content' => 'Jason was born in 2000 and graduated in 1023.']], responseModel: UserDetails::class, diff --git a/src/Clients/Anthropic/AnthropicApiRequest.php b/src/Clients/Anthropic/AnthropicApiRequest.php index 5cb7bebf..18880f8a 100644 --- a/src/Clients/Anthropic/AnthropicApiRequest.php +++ b/src/Clients/Anthropic/AnthropicApiRequest.php @@ -24,6 +24,7 @@ protected function defaultBody(): array { 'messages' => $this->messages(), 'tools' => $this->tools(), 'tool_choice' => $this->getToolChoice(), + 'max_tokens' => $this->maxTokens, ], ) ); diff --git a/src/Clients/Cohere/Traits/HandlesRequestBody.php b/src/Clients/Cohere/Traits/HandlesRequestBody.php index 63530566..9187af35 100644 --- a/src/Clients/Cohere/Traits/HandlesRequestBody.php +++ b/src/Clients/Cohere/Traits/HandlesRequestBody.php @@ -66,7 +66,7 @@ public function tools(): array { return $cohereFormat; } - protected function getToolChoice(): string|array { + public function getToolChoice(): string|array { return ''; } diff --git a/tests/MockLLM.php b/tests/MockLLM.php index cdc60be9..526b6131 100644 --- a/tests/MockLLM.php +++ b/tests/MockLLM.php @@ -18,6 +18,7 @@ static public function get(array $args) : CanCallApi { $mockLLM->shouldReceive('createApiRequest')->andReturnUsing(fn() => new OpenAIApiRequest()); $mockLLM->shouldReceive('getApiRequest')->andReturnUsing(fn() => new OpenAIApiRequest()); $mockLLM->shouldReceive('defaultModel')->andReturn('openai:gpt-4o'); + $mockLLM->shouldReceive('defaultMaxTokens')->andReturn('256'); $mockLLM->shouldReceive('getModeRequestClass')->andReturn(OpenAIApiRequest::class); $mockLLM->shouldReceive('get')->andReturnUsing(...$list); $mockLLM->shouldReceive('request')->andReturn($mockLLM);