googleapis / googleapis/python-genai

Finish Message is Empty when Finish Reason is Malformed Function Call, even when it is populated in logs in AI Studio

Aperta
#1,789 7 commenti 0 reazioni 1 assegnatario Assegnata a @kkorpal Vedi su GitHub
priority: p2 type: bug
Lingua principale
Python
Stelle
4k
Fork
1k
Merge medio
2g 12h
PR unite (30g)
41

Descrizione

When the model stop because of malformed function call, the finish message is empty. This makes retries impossible because the incorrectly generated response is neither in history (`chat.get_history()`) nor in the finish message of the response.

The finish message is correctly populated in the AI Studio logs with what the model tried to generate as malformed function (generally python code instead). So this seems like a python sdk specific problem.

#### Environment details

- Programming language: Python
- OS: Mac Tahoe, Windows 11
- Language runtime version: Python 3.12.3
- Package version: 1.52.0

#### Steps to reproduce

1. Enable logging in Google AI Studio [link](https://ai.google.dev/gemini-api/docs/logs-datasets#1_enable_logging_in_google_ai_studio)
2. Run the notebook at https://github.com/radishbuild/gemini-malformed-function-fix/blob/main/gemini_retry_fix.ipynb
- Make sure to set your GEMINI_API_KEY in .env file
- The notebook runs both error and success case and prints the finish reason
- Notice the print statements in the notebook shows finish message as 'None'
3. View the first log (chronologically earlier), scroll to the bottom to find malformed function call as reason and finish message populated

This user message in a different issue port also shows that finish message is null: [comment](https://github.com/googleapis/python-genai/issues/430#issuecomment-3113739836)

Here is screenshot from google ai studio showing the finish message in logs when python sdk didn't

Image

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.