jpuri commited on
Commit
97c2fa6
·
1 Parent(s): b8ed935
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -20,50 +20,50 @@ def subtract(a: int, b: int) -> int:
20
  """Subtracts the second number from the first and returns the result."""
21
  return a - b
22
 
23
- llm = HuggingFaceInferenceAPI(
24
- model_name="Qwen/Qwen2.5-Coder-32B-Instruct",
25
- )
 
26
 
27
- calculator_agent = ReActAgent(
28
- name="calculator_agent",
29
- description="A calculator agent that can add and subtract numbers.",
30
- system_prompt="You are a calculator assistant. Use your tools for any math operation.",
31
- tools=[add, subtract],
32
- llm=llm,
33
- )
34
 
35
- # Create a vector store
36
- db = chromadb.PersistentClient(path="./alfred_chroma_db")
37
- chroma_collection = db.get_or_create_collection("alfred")
38
- vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
39
 
40
- # Create a query engine
41
- embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
42
- index = VectorStoreIndex.from_vector_store(
43
- vector_store=vector_store, embed_model=embed_model
44
- )
45
- query_engine = index.as_query_engine(llm=llm)
46
- query_engine_tool = QueryEngineTool.from_defaults(
47
- query_engine=query_engine,
48
- name="personas",
49
- description="descriptions for various types of personas",
50
- return_direct=False,
51
- )
52
 
53
- query_agent = ReActAgent(
54
- name="query_agent",
55
- description="A query agent that can query the internet.",
56
- system_prompt="use your tool to query a RAG system to answer informaiton about XYZ.",
57
- tools=[query_engine_tool],
58
- llm=llm,
59
- )
60
 
61
- agent = AgentWorkflow(
62
- agents=[calculator_agent, query_agent],
63
- root_agent="calculator_agent",
64
- )
65
 
66
- async def main():
67
  response = await agent.run(user_msg="What is 10 + 5?")
68
  print(response)
69
 
 
20
  """Subtracts the second number from the first and returns the result."""
21
  return a - b
22
 
23
+ async def main():
24
+ llm = HuggingFaceInferenceAPI(
25
+ model_name="Qwen/Qwen2.5-Coder-32B-Instruct",
26
+ )
27
 
28
+ calculator_agent = ReActAgent(
29
+ name="calculator_agent",
30
+ description="A calculator agent that can add and subtract numbers.",
31
+ system_prompt="You are a calculator assistant. Use your tools for any math operation.",
32
+ tools=[add, subtract],
33
+ llm=llm,
34
+ )
35
 
36
+ # Create a vector store
37
+ db = chromadb.PersistentClient(path="./alfred_chroma_db")
38
+ chroma_collection = db.get_or_create_collection("alfred")
39
+ vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
40
 
41
+ # Create a query engine
42
+ embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
43
+ index = VectorStoreIndex.from_vector_store(
44
+ vector_store=vector_store, embed_model=embed_model
45
+ )
46
+ query_engine = index.as_query_engine(llm=llm)
47
+ query_engine_tool = QueryEngineTool.from_defaults(
48
+ query_engine=query_engine,
49
+ name="personas",
50
+ description="descriptions for various types of personas",
51
+ return_direct=False,
52
+ )
53
 
54
+ query_agent = ReActAgent(
55
+ name="query_agent",
56
+ description="A query agent that can query the internet.",
57
+ system_prompt="use your tool to query a RAG system to answer informaiton about XYZ.",
58
+ tools=[query_engine_tool],
59
+ llm=llm,
60
+ )
61
 
62
+ agent = AgentWorkflow(
63
+ agents=[calculator_agent, query_agent],
64
+ root_agent="calculator_agent",
65
+ )
66
 
 
67
  response = await agent.run(user_msg="What is 10 + 5?")
68
  print(response)
69