Skip to content

Commit

Permalink
use openai response_format
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Jun 20, 2024
1 parent 051a223 commit c0a6c9f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
5 changes: 1 addition & 4 deletions config/translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
],
'openai' => [
'model' => 'gpt-4o',
'prompt' => "
Translate the following json to the locale '{targetLocale}' while preserving the keys.
Your answer must always be a valid and parsable json string.
",
'prompt' => "Translate the following json to the locale '{targetLocale}' while preserving the keys.",
],
],
],
Expand Down
1 change: 1 addition & 0 deletions src/Services/Grammar/OpenAiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function fixAll(array $texts): array
->flatMap(function (Collection $chunk) {
$response = OpenAI::chat()->create([
'model' => $this->model,
'response_format' => ['type' => 'json_object'],
'messages' => [
[
'role' => 'system',
Expand Down
1 change: 1 addition & 0 deletions src/Services/Translate/OpenAiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function translateAll(array $texts, string $targetLocale): array
->flatMap(function (Collection $chunk) use ($targetLocale) {
$response = OpenAI::chat()->create([
'model' => $this->model,
'response_format' => ['type' => 'json_object'],
'messages' => [
[
'role' => 'system',
Expand Down

0 comments on commit c0a6c9f

Please sign in to comment.