File size: 977 Bytes
3370983 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
"""
Simple React Agent implementation with monitoring capabilities.
- React agent:
- https://docs.langchain.com/oss/python/langchain/agents
install:
- langgraph-cli
Run as follows:
>>> cd src/agents/example/
>>> langgraph dev
"""
from langchain.agents import create_agent
from langchain_tavily import TavilySearch
from langchain_core.tools import tool
from dotenv import load_dotenv
load_dotenv()
# --- Tools ---
@tool
def convert_fahrenheit_celsius(fahrenheit: float) -> float:
"""
Convert fahrenheit to celsius.
Args:
fahrenheit (float): Temperature in fahrenheit.
Returns:
float: Temperature in celsius.
"""
return (fahrenheit - 32) * 5.0/9.0
web_search = TavilySearch(
max_results = 5,
topic = "general",
# include_answer = False,
# include_raw_content = False,
# ...
)
tools = [
web_search,
convert_fahrenheit_celsius
]
agent = create_agent(
"gpt-5",
tools=tools
) |