Akshayram1 commited on
Commit
80dcc88
·
verified ·
1 Parent(s): c57b3f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -25,27 +25,32 @@ web_agent = Agent(
25
  markdown=True # Format the output in Markdown
26
  )
27
 
28
- # Function to fetch the latest AI news
29
- def fetch_latest_ai_news():
30
- query = "Find the latest news about Artificial Intelligence and summarize it."
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! This tool provides the latest summaries of AI-related news from the web.
39
 
40
  ---
41
  """)
42
 
43
- if st.button("Fetch Latest AI News"):
44
- st.info("Fetching the latest AI news. This may take a few seconds...")
45
- try:
46
- news_summary = fetch_latest_ai_news()
47
- st.markdown(news_summary) # Display the news summary in Markdown format
48
- except Exception as e:
49
- st.error(f"An error occurred: {str(e)}")
 
 
 
 
 
 
50
  else:
51
- st.write("Click the button above to fetch the latest AI news.")
 
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.")