-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: point to 0.1.12-pre.0 (#922)
- Loading branch information
Showing
104 changed files
with
372 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,43 @@ | ||
# Anthropic Tool Call Example 🛠️🤖 | ||
# Anthropic Tool Call Example 🌟 | ||
|
||
Welcome to the Anthropic Tool Call Example! This fun little project demonstrates how to use the Anthropic API with tool calling capabilities in Go. It's a great way to see how AI models can interact with external tools and functions! | ||
Welcome to the Anthropic Tool Call Example! This fun little Go program demonstrates how to use the Anthropic API to create an AI assistant that can answer questions about the weather using function calling. Let's dive in and see what it does! | ||
|
||
## What's Inside? 📦 | ||
## What Does This Example Do? 🤔 | ||
|
||
This directory contains two main files: | ||
This example showcases the following cool features: | ||
|
||
1. `anthropic-tool-call-example.go`: The star of the show! 🌟 This Go file contains a complete example of how to: | ||
- Set up an Anthropic LLM client | ||
- Define available tools (in this case, a weather function) | ||
- Send queries to the model | ||
- Handle tool calls and responses | ||
- Maintain a conversation history | ||
1. **AI-Powered Weather Assistant**: It creates an AI assistant using Anthropic's Claude model that can answer questions about the weather in different cities. | ||
|
||
2. `go.mod`: The module definition file for this project. It lists the required dependencies, including the awesome `# Anthropic Tool Call Example 🛠️🤖 | ||
2. **Function Calling**: The assistant can use a special tool (function) called `getCurrentWeather` to fetch weather information for specific locations. | ||
|
||
Welcome to the Anthropic Tool Call Example! This fun little project demonstrates how to use the Anthropic API with tool calling capabilities in Go. It's a great way to see how AI models can interact with external tools and functions! | ||
3. **Conversation Flow**: It demonstrates a back-and-forth conversation between a human and the AI assistant, including multiple queries about weather in different cities. | ||
|
||
## What's Inside? 📦 | ||
4. **Tool Execution**: When the AI assistant needs to use the weather tool, the program executes it and provides the results back to the assistant. | ||
|
||
This directory contains a main Go file: | ||
## How It Works 🛠️ | ||
|
||
`anthropic-tool-call-example.go`: The star of the show! 🌟 This Go file contains a complete example of how to: | ||
- Set up an Anthropic LLM client | ||
- Define available tools (in this case, a weather function) | ||
- Send queries to the model | ||
- Handle tool calls and responses | ||
- Maintain a conversation history | ||
1. The program starts by creating an Anthropic client using the Claude 3 Haiku model. | ||
|
||
## What Does It Do? 🤔 | ||
2. It then initiates a conversation by asking about the weather in Boston. | ||
|
||
This example showcases a conversation with an AI model about the weather in different cities. Here's what happens: | ||
3. The AI assistant recognizes the need for weather information and calls the `getCurrentWeather` function. | ||
|
||
1. It sets up an Anthropic LLM client using the Claude 3 Haiku model. | ||
2. Defines a `getCurrentWeather` function as an available tool. | ||
3. Sends an initial query about the weather in Boston. | ||
4. The AI model calls the weather function to get information. | ||
5. The program executes the tool call and sends the result back to the model. | ||
6. The conversation continues with questions about weather in Chicago. | ||
7. The program demonstrates how to maintain context and use tool calls throughout a multi-turn conversation. | ||
4. The program executes the function call, fetching mock weather data for Boston. | ||
|
||
## Cool Features 😎 | ||
5. The AI assistant receives the weather data and formulates a response. | ||
|
||
- **Tool Calling**: Shows how to define and use external tools with the AI model. | ||
- **Conversation History**: Demonstrates maintaining context across multiple interactions. | ||
- **Error Handling**: Includes proper error checking and logging. | ||
- **Flexible Weather Info**: Uses a simple map to simulate weather data for different cities. | ||
6. The conversation continues with additional questions about weather in Chicago, demonstrating the assistant's ability to handle multiple queries and retain context. | ||
|
||
## How to Run 🏃♂️ | ||
## Fun Features 🎉 | ||
|
||
1. Make sure you have Go installed on your system. | ||
2. Set up your Anthropic API key as an environment variable. | ||
3. Run the example with: `go run anthropic-tool-call-example.go` | ||
- **Mock Weather Data**: The example uses a simple map to provide mock weather data for Boston and Chicago. It's not real-time data, but it's perfect for demonstrating how the system works! | ||
|
||
Enjoy exploring the world of AI and tool calling with this fun example! 🎉🤖🌦️ | ||
- **Flexible Conversations**: You can easily modify the conversation flow by adding more questions or changing the cities mentioned. | ||
|
||
- **Tool Definition**: The `availableTools` slice defines the `getCurrentWeather` function, which the AI can use to fetch weather information. | ||
|
||
## Try It Out! 🚀 | ||
|
||
Run the example and watch as the AI assistant cheerfully answers questions about the weather in different cities. Feel free to modify the code to add more cities or even create your own tools for the AI to use! | ||
|
||
Happy coding, and may your weather always be sunny! ☀️ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.