Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -181,14 +181,26 @@ workflow = AgentWorkflow(
|
|
181 |
ctx = Context(workflow)
|
182 |
|
183 |
# Sync wrapper
|
184 |
-
def respond(query: str) -> str:
|
185 |
-
out =
|
186 |
return out.response.blocks[0].text
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
# --- Gradio UI ---
|
189 |
with gr.Blocks() as demo:
|
190 |
-
gr.Markdown("##
|
|
|
|
|
|
|
|
|
|
|
191 |
chatbot = gr.Chatbot()
|
192 |
-
txt
|
193 |
-
|
194 |
-
|
|
|
|
|
|
181 |
ctx = Context(workflow)
|
182 |
|
183 |
# Sync wrapper
|
184 |
+
async def respond(query: str) -> str:
|
185 |
+
out = await workflow.run(user_msg=query, ctx=ctx, memory=memory)
|
186 |
return out.response.blocks[0].text
|
187 |
+
|
188 |
+
# Async response handler for Gradio
|
189 |
+
async def respond_gradio(query, chat_history):
|
190 |
+
answer = await respond(query)
|
191 |
+
return chat_history + [[query, answer]]
|
192 |
|
193 |
# --- Gradio UI ---
|
194 |
with gr.Blocks() as demo:
|
195 |
+
gr.Markdown("## 🤖 Perspicacity")
|
196 |
+
gr.Markdown(
|
197 |
+
"This bot can check the news, tell you the weather, and even browse websites to answer follow-up questions — all powered by a team of tiny AI agents working behind the scenes. \n\n"
|
198 |
+
"🧪 Built for fun during the [AI Agents course](https://huggingface.co/learn/agents-course/unit0/introduction) at Hugging Face — it's just a demo to show what agents can do. \n"
|
199 |
+
"🙌 Got ideas or improvements? PRs welcome!"
|
200 |
+
)
|
201 |
chatbot = gr.Chatbot()
|
202 |
+
txt = gr.Textbox(placeholder="Ask me about news, weather, etc…")
|
203 |
+
|
204 |
+
txt.submit(respond_gradio, inputs=[txt, chatbot], outputs=chatbot)
|
205 |
+
|
206 |
+
demo.launch()
|