langchain-ai / langchain-google

MIT License
111 stars 138 forks source link

ChatGoogleGenerativeAI invoke docs are missing additional keyword params #423

Open gramliu opened 3 months ago

gramliu commented 3 months ago

Docs

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.

image

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

lkuligin commented 3 months ago

thanks for spotting this! would you be open to send a PR with a fix for a docstring, please?