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")