Spaces:
Sleeping
Sleeping
Akshayram1
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ from phi.agent import Agent
|
|
3 |
from phi.model.groq import Groq
|
4 |
from phi.tools.duckduckgo import DuckDuckGo
|
5 |
from dotenv import load_dotenv
|
6 |
-
import time
|
7 |
|
8 |
# Load environment variables
|
9 |
load_dotenv()
|
@@ -26,40 +25,27 @@ web_agent = Agent(
|
|
26 |
markdown=True # Format the output in Markdown
|
27 |
)
|
28 |
|
29 |
-
# Function to fetch the latest AI news
|
30 |
def fetch_latest_ai_news():
|
31 |
-
# Simulating some processing delay
|
32 |
-
time.sleep(3)
|
33 |
-
|
34 |
query = "Find the latest news about Artificial Intelligence and summarize it."
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
st.subheader("Raw Data")
|
57 |
-
st.text_area("Raw Data", value=raw_response, height=300)
|
58 |
-
|
59 |
-
# Display processed (summarized) response
|
60 |
-
st.subheader("Processed Data")
|
61 |
-
st.markdown(processed_response)
|
62 |
-
|
63 |
-
# Running the Streamlit app
|
64 |
-
if __name__ == "__main__":
|
65 |
-
create_streamlit_app()
|
|
|
3 |
from phi.model.groq import Groq
|
4 |
from phi.tools.duckduckgo import DuckDuckGo
|
5 |
from dotenv import load_dotenv
|
|
|
6 |
|
7 |
# Load environment variables
|
8 |
load_dotenv()
|
|
|
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.query(query, stream=False) # Fetch and summarize AI news
|
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.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|