laravel
laravel copied to clipboard
Undefined array key "content"
Similar to our Undefined array key "safetyRatings" issue, we see some calls to the sendMessage function fail. Again, we cannot reproduce this consistently, but it happens in roughly 10% of our calls. A bit more than the safetyRatings issue. And this seems to be more random.
[2024-01-02 14:50:57] local.ERROR: Undefined array key "content" {"exception":"[object] (ErrorException(code: 0): Undefined array key \"content\" at /home/vagrant/code/site/admin/vendor/gemini-api-php/client/src/Resources/Candidate.php:65)
[stacktrace]
#0 /home/vagrant/code/site/admin/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(255): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /home/vagrant/code/site/admin/vendor/gemini-api-php/client/src/Resources/Candidate.php(65): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
#2 /home/vagrant/code/site/admin/vendor/gemini-api-php/client/src/Responses/GenerateContentResponse.php(95): GeminiAPI\\Resources\\Candidate::fromArray()
#3 [internal function]: GeminiAPI\\Responses\\GenerateContentResponse::GeminiAPI\\Responses\\{closure}()
#4 /home/vagrant/code/site/admin/vendor/gemini-api-php/client/src/Responses/GenerateContentResponse.php(94): array_map()
#5 /home/vagrant/code/site/admin/vendor/gemini-api-php/client/src/Client.php(76): GeminiAPI\\Responses\\GenerateContentResponse::fromArray()
#6 /home/vagrant/code/site/admin/vendor/gemini-api-php/client/src/GenerativeModel.php(58): GeminiAPI\\Client->generateContent()
#7 /home/vagrant/code/site/admin/vendor/gemini-api-php/client/src/ChatSession.php(38): GeminiAPI\\GenerativeModel->generateContentWithContents()
#8 /home/vagrant/code/site/admin/vendor/gemini-api-php/laravel/src/ChatSession.php(25): GeminiAPI\\ChatSession->sendMessage()
#9 /home/vagrant/code/site/admin/app/Jobs/AISummary.php(168): GeminiAPI\\Laravel\\ChatSession->sendMessage()
@erdemkose when "finishReason": "SAFETY" response does not have key "content" contents my case: User: Chào bạn, tôi tên là Đức. Hãy nhớ tên tôi nhé Model: Chào Đức, tôi sẽ nhớ tên của bạn. User: Nhắc lại tên tôi nhé --> "finishReason": "SAFETY"