Make sure you have Python 3.8+ installed and the necessary packages (
langchain, langchain-experimental, langchain-openai, langchain-community) available in your environment.Prerequisites
- Tavily API key stored in the
TAVILY_API_KEYenvironment variable - Access to OpenAI’s Chat API via
langchain-openai
Without a valid TAVILY_API_KEY, the search tool will fail to retrieve tournament data. Use
export TAVILY_API_KEY=your_api_key to configure it.1. Import Modules and Initialize Tools
2. Build the Chat Prompt Template
3. Initialize the Agent Executor
4. Example Queries
Below are common examples demonstrating search and computation capabilities.-
Tournament Schedule
-
Hosting Countries
-
Date Calculation
Under the Hood: Python REPL Execution
There are 31 days left before the first match of the ICC Men’s T20 World Cup 2024 starts on June 1, 2024.By combining the Tavily search tool for tournament data and the Python REPL tool for on-the-fly math, the agent can answer complex queries accurately and interactively.