Spaces:
Sleeping
Sleeping
Akshayram1
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -25,27 +25,32 @@ web_agent = Agent(
|
|
25 |
markdown=True # Format the output in Markdown
|
26 |
)
|
27 |
|
28 |
-
# Function to fetch
|
29 |
-
def
|
30 |
-
|
31 |
-
response = web_agent.execute(query) # Fetch and summarize AI news using 'execute' method
|
32 |
return response
|
33 |
|
34 |
# Streamlit App
|
35 |
st.title("AI News Fetcher")
|
36 |
|
37 |
st.markdown("""
|
38 |
-
Welcome to the **AI News Fetcher** app!
|
39 |
|
40 |
---
|
41 |
""")
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
else:
|
51 |
-
st.write("
|
|
|
25 |
markdown=True # Format the output in Markdown
|
26 |
)
|
27 |
|
28 |
+
# Function to fetch news based on user query
|
29 |
+
def fetch_news(query):
|
30 |
+
response = web_agent.execute(query) # Fetch and summarize news using 'execute' method
|
|
|
31 |
return response
|
32 |
|
33 |
# Streamlit App
|
34 |
st.title("AI News Fetcher")
|
35 |
|
36 |
st.markdown("""
|
37 |
+
Welcome to the **AI News Fetcher** app! Enter your query to find the latest summaries of AI-related news or any topic of interest.
|
38 |
|
39 |
---
|
40 |
""")
|
41 |
|
42 |
+
# User input for query
|
43 |
+
user_query = st.text_input("Enter your query:", placeholder="Find the latest news about AI, summarize advancements in robotics, etc.")
|
44 |
+
|
45 |
+
if st.button("Fetch News"):
|
46 |
+
if user_query.strip():
|
47 |
+
st.info("Fetching the news. This may take a few seconds...")
|
48 |
+
try:
|
49 |
+
news_summary = fetch_news(user_query)
|
50 |
+
st.markdown(news_summary) # Display the news summary in Markdown format
|
51 |
+
except Exception as e:
|
52 |
+
st.error(f"An error occurred: {str(e)}")
|
53 |
+
else:
|
54 |
+
st.warning("Please enter a valid query.")
|
55 |
else:
|
56 |
+
st.write("Enter a query and click the button to fetch news.")
|