cookbook icon indicating copy to clipboard operation
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"

Open eawlot3000 opened this issue 9 months ago • 1 comments

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.

  1. 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.

  2. Streamed Responses Issue: The documentation example for streamed responses is incorrect. When executing the provided code, an AttributeError is raised.

Steps to Reproduce:

  1. 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.
  2. 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:

  1. The text-only example should use a non-vision model to avoid the error.
  2. The streamed response example should work without raising an AttributeError.

Actual Behavior:

  1. 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]
    
  2. 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 avatar May 15 '24 21:05 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.

image

singhniraj08 avatar May 20 '24 04:05 singhniraj08

@singhniraj08 uh oh, wrong place. Got it! I will try to submit there. Thanks

eawlot3000 avatar May 25 '24 23:05 eawlot3000