Spaces:
Running
Running
File size: 2,097 Bytes
23f2703 |
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 46 47 48 49 50 51 52 53 54 55 56 |
import streamlit as st
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
# Define agents for both functionalities
search_agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
blog_agent = CodeAgent(tools=[], model=HfApiModel()) # Replace with blog-specific tools/models if needed
# Streamlit app title
st.title("AI Agent Hub: Blog Writing & Stock Data Retrieval")
# Main navigation options
st.sidebar.header("Select a Feature")
selected_feature = st.sidebar.radio(
"What would you like to do?",
("Blog Writing Agent", "Stock Data Helper")
)
# Prompt input and execution logic
if selected_feature == "Blog Writing Agent":
st.header("Blog Writing Agent")
blog_prompt = st.text_area("Enter your blog topic or prompt:")
if st.button("Generate Blog Content"):
if blog_prompt:
with st.spinner("Generating blog content..."):
try:
# Run the blog agent
blog_result = blog_agent.run(blog_prompt)
st.write("Generated Blog Content:")
st.write(blog_result)
except Exception as e:
st.error(f"An error occurred: {e}")
else:
st.warning("Please enter a blog prompt to continue.")
elif selected_feature == "Stock Data Helper":
st.header("Stock Data Helper")
stock_prompt = st.text_area("Enter your query (e.g., company name, stock symbol):")
if st.button("Retrieve Stock Data"):
if stock_prompt:
with st.spinner("Retrieving stock data..."):
try:
# Run the search agent for stock data
stock_result = search_agent.run(stock_prompt)
st.write("Stock Data Result:")
st.write(stock_result)
except Exception as e:
st.error(f"An error occurred: {e}")
else:
st.warning("Please enter a stock-related query to continue.")
# Footer
st.markdown("---")
st.caption("Powered by SmolAgents and Streamlit")
|