Thanks to visit codestin.com
Credit goes to github.com

Skip to content

InternalServerError in ChatSession.send_message with Empty String #133

@Hamza-nabil

Description

@Hamza-nabil

Description of the bug:

When passing empty message to ChatSession.send_message it triggers a 500 Internal Server Error.

Here is an example :

import google.generativeai as genai

genai.configure(api_key ="YOUR API KEY")

model = genai.GenerativeModel(model_name='gemini-pro')

chat = model.start_chat(history=[])
response = chat.send_message("")

Actual vs expected behavior:

Actual behavior:

InternalServerError: 500 POST https://dp.kaggle.net/palmapi/v1beta/models/gemini-pro:generateContent?%24alt=json%3Benum-encoding%3Dint: An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting

Actual behavior:
Should be handled in the same way as it is in GenerativeModel.generate_content :

TypeError: contents must not be empty

Any other information you'd like to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions