cookbook
cookbook copied to clipboard
Two bugs in your gemini api doc need to be fixed, please: "Inconsistent Documentation and Errors with Text-Only Models and Streamed Responses"
The overall reference link: Google Gemini API Documentation
Description of the Bug:
Title: Inconsistent Documentation and Errors with Text-Only Models and Streamed Responses
Description: I encountered several issues while using the Google Gemini API, specifically related to text-only input and streamed responses.
-
Text-Only Input Issue: The documentation states that the Gemini API can handle text-only input. However, the example provided uses the 'gemini-pro-vision' model, which requires an image. This causes an error when executed.
-
Streamed Responses Issue: The documentation example for streamed responses is incorrect. When executing the provided code, an
AttributeError
is raised.
Steps to Reproduce:
-
For Text-Only Input Issue:
- Refer to the documentation here.
- Use the provided example code:
model = genai.GenerativeModel('gemini-pro-vision') prompt = "Write a story about a magic backpack." response = model.generate_content(prompt)
- Run the code in the terminal on macOS with Python 3.10.
-
For Streamed Responses Issue:
- Refer to the documentation here.
- Use the provided example code:
prompt = "Write a story about a magic backpack." response = genai.stream_generate_content( model="models/gemini-pro", prompt=prompt )
- Run the code in the terminal on macOS with Python 3.10.
Expected Behavior:
- The text-only example should use a non-vision model to avoid the error.
- The streamed response example should work without raising an
AttributeError
.
Actual Behavior:
-
Text-Only Input Issue: When running the text-only example, I received the following error:
google.api_core.exceptions.InvalidArgument: 400 Add an image to use models/gemini-pro-vision, or switch your model to a text model. [Process exited 1]
-
Streamed Responses Issue: When running the streamed response example, I received the following error:
Traceback (most recent call last): File "xxxxxxxxxxsomething/here/test.py", line 46, in <module> response = genai.stream_generate_content( AttributeError: module 'google.generativeai' has no attribute 'stream_generate_content' [Process exited 1]
Development Environment:
- OS: macOS
- Python Version: 3.10
- Terminal: Built-in macOS Terminal App
Please address these documentation errors to ensure the examples work correctly for users.
Thanks,
github user @eawlot3000
@eawlot3000, Thank you reporting this issue. This repository is for issues related to collection of guides and examples for the Gemini API like bugs or improvements. For issues related to Gemini, we would suggest you to use "Send Documentation Feedback" option in Gemini docs. Ref: Screenshot below.
@singhniraj08 uh oh, wrong place. Got it! I will try to submit there. Thanks