langchain-ai / langchain-google

MIT License
104 stars 121 forks source link

add response_mime_type for gemini models (allow JSON-mode output, optionally) #228

Closed nicsuzor closed 3 months ago

nicsuzor commented 4 months ago

Minor change to optionally add response_mime_type to generation_config. Note this is a preview feature in the Vertex API available for gemini-1.5-pro: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini#parameters

Fulfills #144.

lkuligin commented 4 months ago

Thanks for your contribution!

response_mime_type was already supported and passed as part as kwargs: https://github.com/langchain-ai/langchain-google/blob/d4dcff348e02751605d487b5c1979c7369437636/libs/vertexai/langchain_google_vertexai/chat_models.py#L122

if you feel like we should also allow to setup its default value during model initialization, I'd suggest to redefine the _default_params property (by adding response_mime_type to super()._default_params).

So that similar things are defined at similar place, and the logic not being spread all over the code base. WDYT?

nicsuzor commented 4 months ago

if you feel like we should also allow to setup its default value during model initialization, I'd suggest to redefine the _default_params property (by adding response_mime_type to super()._default_params).

So that similar things are defined at similar place, and the logic not being spread all over the code base. WDYT?

Sure thing, I've updated that now.

lkuligin commented 3 months ago

@nicsuzor could you finalize it, please?

nicsuzor commented 3 months ago

@lkuligin Yup, edited accordingly.

lkuligin commented 3 months ago

/gcbrun

lkuligin commented 3 months ago

/gcbrun

lkuligin commented 3 months ago

/gcbrun