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.19k stars 227 forks source link

Tuned models return no content! #370

Closed maelghrib closed 1 week ago

maelghrib commented 1 month ago

Description of the bug:

So I tuned the model using Python and it worked and completed as shown in the platform without any errors but when I tried using it in the studio it returned "No content" and when testing it with Python

Here is the code:

import google.generativeai as genai

generation_config = {
    "temperature": 0,
    "top_p": 1,
    "top_k": 1,
    "max_output_tokens": 400,
}

safety_settings = [
    {
        "category": "HARM_CATEGORY_HARASSMENT",
        "threshold": "BLOCK_NONE"
    },
    {
        "category": "HARM_CATEGORY_HATE_SPEECH",
        "threshold": "BLOCK_NONE"
    },
    {
        "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        "threshold": "BLOCK_NONE"
    },
    {
        "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
        "threshold": "BLOCK_NONE"
    },
]

name = "my-tuned-model"
model = genai.GenerativeModel(
    model_name=f"tunedModels/{name}",
    generation_config=generation_config,
    safety_settings=safety_settings
)

prompt_parts = [
    "input: my input here",
    "output: ",
]

response = model.generate_content(prompt_parts)
print(response)

and here is the response:

response:
GenerateContentResponse(
    done=True,
    iterator=None,
    result=glm.GenerateContentResponse({
      "candidates": []
    }),
)

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

singhniraj08 commented 1 month ago

@maelghrib, Thank you reporting this issue. This looks like an intermittent error and should work now. This repository is for issues related to Python SDK client bugs or improvements and the client doesn't control the service's responses. For issues related to Gemini API, we would suggest you to use "Send Feedback" option in Gemini docs. Ref: Screenshot below. You can also post this issue on Discourse forum.

image

maelghrib commented 1 month ago

Hi @singhniraj08 Okay I posted in the forum and sent a feedback, Thanks

github-actions[bot] commented 3 weeks ago

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 28 days. Please post a new issue if you need further assistance. Thanks!