AI Learning Notes #01 — How LLM Tool Calling Works
Without @tool , this is simply a Python function. The important thing is that @tool turns it into a LangChain tool . @ tool def get_stock_price ( ticker : str ) -> str : """Fetches the mock current stock price for a given ticker symbol (e.g., AAPL, GOOGL).""" mock_prices = { "AAPL" : 220.50 , "GOOGL" : 175.30 , "MSFT" : 415.00 } price = mock_prices . get ( ticker . upper (), 100.00 ) return json . dumps ({ "ticker" : ticker . upper (), "price_usd" : price }) This is loading environment vairables # Load environment variables (GOOGLE_API_KEY / GEMINI_API_KEY) load_dotenv () After loading the environment variable you can call ChatGoogleGenerativeAI ( model, temperature) it will by default get the value environment of " GOOGLE_API_KEY " variable. You need not to care too much. llm = ChatGoogleGenerativeAI ( model = "gemini-2.5-flash" , temperature = 0.0 ...