Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
| 3 |
+
|
| 4 |
+
# Define agents for both functionalities
|
| 5 |
+
search_agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
|
| 6 |
+
blog_agent = CodeAgent(tools=[], model=HfApiModel()) # Replace with blog-specific tools/models if needed
|
| 7 |
+
|
| 8 |
+
# Streamlit app title
|
| 9 |
+
st.title("AI Agent Hub: Blog Writing & Stock Data Retrieval")
|
| 10 |
+
|
| 11 |
+
# Main navigation options
|
| 12 |
+
st.sidebar.header("Select a Feature")
|
| 13 |
+
selected_feature = st.sidebar.radio(
|
| 14 |
+
"What would you like to do?",
|
| 15 |
+
("Blog Writing Agent", "Stock Data Helper")
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
# Prompt input and execution logic
|
| 19 |
+
if selected_feature == "Blog Writing Agent":
|
| 20 |
+
st.header("Blog Writing Agent")
|
| 21 |
+
blog_prompt = st.text_area("Enter your blog topic or prompt:")
|
| 22 |
+
|
| 23 |
+
if st.button("Generate Blog Content"):
|
| 24 |
+
if blog_prompt:
|
| 25 |
+
with st.spinner("Generating blog content..."):
|
| 26 |
+
try:
|
| 27 |
+
# Run the blog agent
|
| 28 |
+
blog_result = blog_agent.run(blog_prompt)
|
| 29 |
+
st.write("Generated Blog Content:")
|
| 30 |
+
st.write(blog_result)
|
| 31 |
+
except Exception as e:
|
| 32 |
+
st.error(f"An error occurred: {e}")
|
| 33 |
+
else:
|
| 34 |
+
st.warning("Please enter a blog prompt to continue.")
|
| 35 |
+
|
| 36 |
+
elif selected_feature == "Stock Data Helper":
|
| 37 |
+
st.header("Stock Data Helper")
|
| 38 |
+
stock_prompt = st.text_area("Enter your query (e.g., company name, stock symbol):")
|
| 39 |
+
|
| 40 |
+
if st.button("Retrieve Stock Data"):
|
| 41 |
+
if stock_prompt:
|
| 42 |
+
with st.spinner("Retrieving stock data..."):
|
| 43 |
+
try:
|
| 44 |
+
# Run the search agent for stock data
|
| 45 |
+
stock_result = search_agent.run(stock_prompt)
|
| 46 |
+
st.write("Stock Data Result:")
|
| 47 |
+
st.write(stock_result)
|
| 48 |
+
except Exception as e:
|
| 49 |
+
st.error(f"An error occurred: {e}")
|
| 50 |
+
else:
|
| 51 |
+
st.warning("Please enter a stock-related query to continue.")
|
| 52 |
+
|
| 53 |
+
# Footer
|
| 54 |
+
st.markdown("---")
|
| 55 |
+
st.caption("Powered by SmolAgents and Streamlit")
|