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.62k stars 322 forks source link

GenerationConfig Error: 'seed' Field Missing in Protocol Message but Present in GenerationConfig Class #605

Closed emersoftware closed 3 weeks ago

emersoftware commented 1 month ago

Description of the feature request:

I'm trying to set the seed for Gemini using the 'google-generativeai' library:

model = genai.GenerativeModel(
    model_name,
    system_instruction=system_instruction,
    generation_config=GenerationConfig(
        temperature=0.0,
        seed=42
    )
)

However, I'm getting the following error:

"ValueError: Protocol message GenerationConfig has no \"seed\" field."

I understand that this happens because the GenerationConfig(proto.Message)class from google.generativeai.types doesn't have a seed attribute. However, this attribute does exist in the GenerationConfig class, which is accepted as a type in GenerationConfigType = Union[protos.GenerationConfig, GenerationConfigDict, GenerationConfig] from google.generativeai.types.

I believe this is an inconsistency

What problem are you trying to solve with this feature?

I would like to set a seed value in the GenerationConfig when using the Gemini API to ensure reproducibility of the generated output. Since the seed attribute already exists in the GenerationConfig class, adding support for it in protos.GenerationConfig would provide a more consistent experience

Any other information you'd like to share?

No response

gmKeshari commented 1 month ago

Hi @emersoftware.

Seed attribute is still not present in Gemini API SDK, but it is present in VertexAI SDK. The team is working to have this attribute in the Gemini API SDK as well.

We have a similar GitHub discussion. If you wanna refer please go through this #536

MarkDaoust commented 1 month ago

Yeah, we thought this was going to make it into the last release of the API, and then it didn't. Let's remove it from the SDK until it's supported.

MarkDaoust commented 1 month ago

https://github.com/google-gemini/generative-ai-python/pull/609