Skip to content

Commit bd3f79d

Browse files
authored
bug(mistral): reinstate tool choice and topP (#241)
1 parent d12bf69 commit bd3f79d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Providers/Mistral/Handlers/Text.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PrismPHP\Prism\Providers\Mistral\Concerns\MapsFinishReason;
1212
use PrismPHP\Prism\Providers\Mistral\Concerns\ValidatesResponses;
1313
use PrismPHP\Prism\Providers\Mistral\Maps\MessageMap;
14+
use PrismPHP\Prism\Providers\Mistral\Maps\ToolChoiceMap;
1415
use PrismPHP\Prism\Providers\Mistral\Maps\ToolMap;
1516
use PrismPHP\Prism\Text\Request;
1617
use PrismPHP\Prism\Text\Response;
@@ -130,13 +131,15 @@ protected function addStep(array $data, Request $request, array $toolResults = [
130131
protected function sendRequest(Request $request): array
131132
{
132133
try {
133-
$response = $this->client->post('chat/completions', [
134+
$response = $this->client->post('chat/completions', array_filter([
134135
'model' => $request->model(),
135136
'messages' => (new MessageMap($request->messages(), $request->systemPrompts()))(),
136137
'tools' => ToolMap::map($request->tools()),
137138
'temperature' => $request->temperature(),
138139
'max_tokens' => $request->maxTokens(),
139-
]);
140+
'top_p' => $request->topP(),
141+
'tool_choice' => ToolChoiceMap::map($request->toolChoice()),
142+
]));
140143

141144
return $response->json();
142145
} catch (Throwable $e) {

tests/Providers/Mistral/MistralTextTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
});
129129

130130
it('throws an exception for ToolChoice::Any', function (): void {
131+
Http::preventStrayRequests();
132+
131133
$this->expectException(PrismException::class);
132134
$this->expectExceptionMessage('Invalid tool choice');
133135

0 commit comments

Comments
 (0)