openai-php / laravel

⚡️ OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with OpenAI API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Character Encoding Issue

ignacio-dev opened this issue · comments

Not sure if this issue has to do with this package, or with the API itself (if not related to this package, please let me know and I will delete this issue from here).

But basically, all characters with tildes are being omitted.

For example, some Spanish words like "canción" are returning as "cancin".

It works for me:

$client = OpenAI::client('****');

$response = $client->chat()->create([
    'model' => 'gpt-3.5-turbo',
    'messages' => [
        ['role' => 'user', 'content' => 'Translate to spanish: "song"'],
    ],
]);

dd($response->toArray());


// output
array:6 [
  "id" => "chatcmpl-7KCInnSn7CuzFDOOnBW5azJuWqIA9"
  "object" => "chat.completion"
  "created" => 1685048205
  "model" => "gpt-3.5-turbo-0301"
  "choices" => array:1 [
    0 => array:3 [
      "index" => 0
      "message" => array:2 [
        "role" => "assistant"
        "content" => "canción" // <------- SEE HERE
      ]
      "finish_reason" => "stop"
    ]
  ]
  "usage" => array:3 [
    "prompt_tokens" => 15
    "completion_tokens" => 3
    "total_tokens" => 18
  ]
]