Spaces:
Sleeping
Sleeping
Add .gitignore for Python bytecode files and refactor agent interaction to use async
Browse files- .gitignore +1 -0
- app.py +7 -2
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*.pyc
|
app.py
CHANGED
|
@@ -5,6 +5,7 @@ from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI
|
|
| 5 |
from tools import get_weather_info_tool, get_hub_stats_tool, search_tool
|
| 6 |
from retriever import guest_info_tool
|
| 7 |
import gradio as gr
|
|
|
|
| 8 |
|
| 9 |
llm = HuggingFaceInferenceAPI(model_name='Qwen/Qwen2.5-Coder-32B-Instruct')
|
| 10 |
alfred = AgentWorkflow.from_tools_or_functions(
|
|
@@ -19,10 +20,14 @@ alfred = AgentWorkflow.from_tools_or_functions(
|
|
| 19 |
)
|
| 20 |
|
| 21 |
# Define a function to interact with the AgentWorkflow
|
| 22 |
-
def
|
| 23 |
-
response = alfred.run(input_text)
|
| 24 |
return response
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
if __name__ == "__main__":
|
| 27 |
# Create a Gradio interface
|
| 28 |
interface = gr.Interface(
|
|
|
|
| 5 |
from tools import get_weather_info_tool, get_hub_stats_tool, search_tool
|
| 6 |
from retriever import guest_info_tool
|
| 7 |
import gradio as gr
|
| 8 |
+
import asyncio
|
| 9 |
|
| 10 |
llm = HuggingFaceInferenceAPI(model_name='Qwen/Qwen2.5-Coder-32B-Instruct')
|
| 11 |
alfred = AgentWorkflow.from_tools_or_functions(
|
|
|
|
| 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):
|
| 28 |
+
# Ensure the async function is run in an event loop
|
| 29 |
+
return asyncio.run(async_interact_with_agent(input_text))
|
| 30 |
+
|
| 31 |
if __name__ == "__main__":
|
| 32 |
# Create a Gradio interface
|
| 33 |
interface = gr.Interface(
|