Hello there! Welcome to this exciting example that demonstrates how to use Google AI's language model with tool calling capabilities. Let's dive in and see what this cool code does!
What's This All About? π€
This example shows you how to:
- Set up a conversation with Google AI's language model
- Define and use custom tools (functions) that the AI can call
- Handle the AI's responses and tool calls
- Provide tool call results back to the AI
The Weather Inquiry Adventure π¦οΈ
Here's what happens in this fun little program:
- We start by asking the AI about the weather in Chicago.
- We give the AI a special tool called
getCurrentWeather
that it can use to check the weather.
- The AI recognizes it needs more info and calls the
getCurrentWeather
function.
- Our code "executes" this function call (it's just pretend data for this example).
- We send the weather info back to the AI.
- The AI then gives us a final response about the weather in Chicago!
Cool Features π
- Uses the
github.com/czc09/langchaingo
library to interact with Google AI
- Demonstrates how to set up and use custom tools with the AI
- Shows how to maintain a conversation history for context
- Handles tool calls and responses in a neat way
How to Run πββοΈ
- Make sure you have Go installed on your machine.
- Set the
GENAI_API_KEY
environment variable with your Google AI API key.
- Run the program with
go run googleai-tool-call-example.go
What You'll See π
When you run the program, you'll see the AI's final response after the tool call. It should include a friendly message about the weather in Chicago, based on the information our mock getCurrentWeather
function provided!
Have fun exploring this example and learning about AI tool calls! ππ€