The docs for ChatGoogleGenerativeAI are missing additional keyword params. Looking at the source code, there are additional kwargs for tools, functions, safety_settings, tool_config, and generation_config.
However, the docs only mention a separate config parameter.
API Inconsistency
This made it confusing for me to figure out how to actually specify the temperature for a specific invoke call (not at model instantiation). Code snippet that actually works but isn't documented:
from langchain_google_genai import ChatGoogleGenerativeAI
from dotenv import load_dotenv
load_dotenv()
gemini_pro = ChatGoogleGenerativeAI(model="gemini-1.5-flash", temperature=0, max_tokens=1000)
gemini_pro.invoke("What's your favorite color'?", generation_config={ "temperature": 0.1 })
Additionally, I think it makes sense for temperature to at the very least be parsed out from the main kwargs, without the need to specify the generation_config parameter. The following code snippet works out of the box for other models:
claude = ChatAnthropic(model="claude-3-opus-20240229", temperature=0, max_tokens=1000)
claude.invoke("What's your favorite color'?", temperature=0.1)
so it would make sense that it should also be supported for Google models
Docs
The docs for
ChatGoogleGenerativeAI
are missing additional keyword params. Looking at the source code, there are additional kwargs fortools
,functions
,safety_settings
,tool_config
, andgeneration_config
.However, the docs only mention a separate
config
parameter.API Inconsistency
This made it confusing for me to figure out how to actually specify the temperature for a specific
invoke
call (not at model instantiation). Code snippet that actually works but isn't documented:Additionally, I think it makes sense for
temperature
to at the very least be parsed out from the mainkwargs
, without the need to specify thegeneration_config
parameter. The following code snippet works out of the box for other models:so it would make sense that it should also be supported for Google models