Spaces:
Sleeping
Sleeping
Refactor async interaction with AgentWorkflow to include context parameter
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from llama_index.core.agent.workflow import AgentWorkflow
|
| 2 |
from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI
|
|
|
|
| 3 |
|
| 4 |
# Import our custom tools from their modules
|
| 5 |
from tools import get_weather_info_tool, get_hub_stats_tool, search_tool
|
|
@@ -19,9 +20,10 @@ alfred = AgentWorkflow.from_tools_or_functions(
|
|
| 19 |
verbose=True,
|
| 20 |
)
|
| 21 |
|
|
|
|
| 22 |
# Define a function to interact with the AgentWorkflow
|
| 23 |
-
async def async_interact_with_agent(input_text):
|
| 24 |
-
response = await alfred.run(input_text)
|
| 25 |
return response
|
| 26 |
|
| 27 |
def interact_with_agent(input_text):
|
|
|
|
| 1 |
from llama_index.core.agent.workflow import AgentWorkflow
|
| 2 |
from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI
|
| 3 |
+
from llama_index.core.workflow import Context
|
| 4 |
|
| 5 |
# Import our custom tools from their modules
|
| 6 |
from tools import get_weather_info_tool, get_hub_stats_tool, search_tool
|
|
|
|
| 20 |
verbose=True,
|
| 21 |
)
|
| 22 |
|
| 23 |
+
ctx = Context(alfred)
|
| 24 |
# Define a function to interact with the AgentWorkflow
|
| 25 |
+
async def async_interact_with_agent(input_text, ctx=ctx):
|
| 26 |
+
response = await alfred.run(input_text, ctx=ctx)
|
| 27 |
return response
|
| 28 |
|
| 29 |
def interact_with_agent(input_text):
|