Spaces:
Sleeping
Sleeping
File size: 1,305 Bytes
69a077e c8844e4 69a077e 7efd3cf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # app.py
import gradio as gr
import asyncio
from chat_agent import SimpleChatAgent
agent = SimpleChatAgent()
async def async_chat_fn(message, history):
return await agent.handle_query(message, history)
def chat_fn(message, history):
return asyncio.run(async_chat_fn(message, history))
with gr.Blocks(css="""
#title { font-size: 2.2rem; font-weight: bold; text-align: center; margin-bottom: 0.5em; color: #2e3a59; }
#desc { font-size: 1.1rem; text-align: center; color: #6c7a92; margin-bottom: 2em; }
footer { text-align: center; font-size: 0.9rem; color: #999; margin-top: 2em; }
.gradio-container { background-color: #f9fbfc; }
""") as demo:
gr.Markdown("<div id='title'> Chat + Web Scraper Agent</div>")
gr.Markdown("<div id='desc'>Ask anything, or tell me to scrape a webpage. your custom agent logic.</div>")
with gr.Row():
with gr.Column(scale=1):
gr.ChatInterface(
fn=chat_fn,
chatbot=gr.Chatbot(show_copy_button=True),
textbox=gr.Textbox(placeholder="Type your question or paste a URL to scrape...", show_label=False),
title=None,
theme="soft",
)
gr.Markdown("<footer>Built with ❤️ using LLM + Gradio UI</footer>")
demo.launch(mcp_server = True)
|