Spaces:
Running
Running
File size: 1,216 Bytes
d07654f |
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 38 39 40 41 42 43 44 45 |
import gradio as gr
from research import research
from textblob import TextBlob
def research_query(query):
"""
Function to handle research queries through Gradio interface
Args:
text (str): The query to perform websearch and provide summary.
Returns:
text (str): A detailed summary on the query asked by perfoming web search.
"""
if not query.strip():
return "Please enter a valid query"
try:
result = research(query)
return result
except Exception as e:
return f"Error processing query: {str(e)}"
# Create Gradio interface
demo = gr.Interface(
fn=research_query,
inputs=gr.Textbox(
lines=3,
placeholder="Enter your research query here...",
label="Research Query"
),
outputs=gr.Textbox(
lines=10,
label="Research Results"
),
title="Research Assistant",
description="Enter a query to get detailed research results using ReAct agent.",
examples=[
["What are the latest developments in quantum computing?"],
["Explain the impact of artificial intelligence on healthcare"],
]
)
if __name__ == "__main__":
demo.launch(mcp_server=True)
|