Spaces:
Runtime error
Runtime error
update
Browse files
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 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
-
calculator_agent = ReActAgent(
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 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 |
-
|
| 44 |
-
)
|
| 45 |
-
query_engine = index.as_query_engine(llm=llm)
|
| 46 |
-
query_engine_tool = QueryEngineTool.from_defaults(
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
)
|
| 52 |
|
| 53 |
-
query_agent = ReActAgent(
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
)
|
| 60 |
|
| 61 |
-
agent = AgentWorkflow(
|
| 62 |
-
|
| 63 |
-
|
| 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 |
|