Pycrolis commited on
Commit
5e2ccaa
·
1 Parent(s): d8b8674

feat(tool): add web search capability.

Browse files

Integrate Tavily web search functionality

Files changed (2) hide show
  1. README.md +13 -2
  2. ShrewdAgent.py +2 -1
README.md CHANGED
@@ -15,10 +15,21 @@ short_description: Agent for the final hands-on assignment of the Agents course
15
 
16
  ## Requirements
17
 
18
- To run this project, you need to have an OpenAI API key. Set your `OPENAI_API_KEY` as an environment variable:
 
 
19
 
 
 
 
 
 
 
20
  ```bash
21
  export OPENAI_API_KEY='your-api-key'
 
22
  ```
23
 
24
- You can get your OpenAI API key from [here](https://platform.openai.com/account/api-keys).
 
 
 
15
 
16
  ## Requirements
17
 
18
+ ### Prerequisites
19
+ - Python 3.x
20
+ - Virtual environment (recommended)
21
 
22
+ ### API Keys
23
+ This project requires the following API keys:
24
+ - OpenAI API key
25
+ - Tavily API key
26
+
27
+ Set them as environment variables:
28
  ```bash
29
  export OPENAI_API_KEY='your-api-key'
30
+ export TAVILY_API_KEY='your-api-key'
31
  ```
32
 
33
+ You can get the required API keys here:
34
+ - OpenAI API key: [OpenAI Platform](https://platform.openai.com/account/api-keys)
35
+ - Tavily API key: [Tavily](https://tavily.com)
ShrewdAgent.py CHANGED
@@ -4,6 +4,7 @@ from typing import TypedDict, Annotated, Optional, Any, Callable, Sequence, Unio
4
  from langchain_core.messages import AnyMessage, SystemMessage, HumanMessage
5
  from langchain_core.tools import BaseTool
6
  from langchain_openai import ChatOpenAI
 
7
  from langgraph.constants import START
8
  from langgraph.errors import GraphRecursionError
9
  from langgraph.graph import add_messages, StateGraph
@@ -32,7 +33,7 @@ class ShrewdAgent:
32
  Important: Your final output must be only a number or a short phrase, with no additional text or explanation."""
33
 
34
  def __init__(self):
35
- self.tools = []
36
  self.llm = ChatOpenAI(
37
  model="gpt-4o-mini",
38
  temperature=0,
 
4
  from langchain_core.messages import AnyMessage, SystemMessage, HumanMessage
5
  from langchain_core.tools import BaseTool
6
  from langchain_openai import ChatOpenAI
7
+ from langchain_tavily import TavilySearch
8
  from langgraph.constants import START
9
  from langgraph.errors import GraphRecursionError
10
  from langgraph.graph import add_messages, StateGraph
 
33
  Important: Your final output must be only a number or a short phrase, with no additional text or explanation."""
34
 
35
  def __init__(self):
36
+ self.tools = [TavilySearch()]
37
  self.llm = ChatOpenAI(
38
  model="gpt-4o-mini",
39
  temperature=0,