google-gemini / generative-ai-python

The official Python library for the Google Gemini API
https://pypi.org/project/google-generativeai/
Apache License 2.0
1.3k stars 252 forks source link

gemini-1.0-pro-vision-001 incorrectly interrupts requests for recitation reason #253

Open cinhil opened 5 months ago

cinhil commented 5 months ago

Description of the bug:

Hello

Simple request bellow will succeed when addressed to gemini-pro but failed on gemini-pro-vision. This is the very basic request to reproduce but it occurs a lot with multimodal requests too.

import vertexai
from vertexai.generative_models import GenerativeModel

model = GenerativeModel("gemini-1.0-pro-vision-001")
response = model.generate_content("Count from 1 to 100, print numbers as words", stream=True)
for chunk in response:
    try:
        print(chunk.text)
    except Exception as e:
        print(e)
        for candidate in chunk.candidates:
            print(f"Finish reason: {candidate.finish_reason} - {candidate.finish_message}")

Result:

1. One
2. Two
3. Three
4. Four
5. Five
6. Six
7. Seven
8. Eight
9. Nine

Content has no parts.
Finish reason: 4 -

I don't know where is the best place to report it.

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

LindaLawton commented 4 months ago

You are using vertex ai this repo is for gemini ai you may want to post on python-aiplatform