File size: 859 Bytes
f016beb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# src/agent.py
from langchain.agents import create_react_agent, AgentExecutor
from src.config import groq_llm
from src.tools.python_tool import python_tool
from langchain.hub import pull
from src.tools.serper_search import serper_search_tool
from src.tools.file_loader import file_loader_tool


llm   = groq_llm(model="llama3-70b-8192")
tools = [python_tool, serper_search_tool, file_loader_tool]
prompt = pull("hwchase17/react")

agent = create_react_agent(llm=llm, tools=tools, prompt=prompt)

agent_executor = AgentExecutor(
    agent=agent,
    tools=tools,
    verbose=True,
    handle_parsing_errors=True,   # retry if the model slips
)

if __name__ == "__main__":
    print(agent_executor.invoke({
    "input": "Load this tiny sample CSV and show me the first rows: "
             "https://people.sc.fsu.edu/~jburkardt/data/csv/hw_200.csv"
        }))