Ina-Shapiro commited on
Commit
2353d31
·
verified ·
1 Parent(s): 933f945

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -0
app.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
3
+
4
+ # Configure Streamlit page
5
+ st.set_page_config(
6
+ page_title="AI Agents",
7
+ page_icon="🤖",
8
+ layout="wide"
9
+ )
10
+
11
+ # Initialize agents
12
+ @st.cache_resource
13
+ def load_agents():
14
+ agents = {}
15
+
16
+ # Search Agent
17
+ agents["Search Agent"] = CodeAgent(
18
+ tools=[DuckDuckGoSearchTool()],
19
+ model=HfApiModel("microsoft/DialoGPT-medium")
20
+ )
21
+
22
+ # You can add more agents here
23
+ # agents["Math Agent"] = CodeAgent(
24
+ # tools=[], # Add math tools here
25
+ # model=HfApiModel("microsoft/DialoGPT-medium")
26
+ # )
27
+
28
+ return agents
29
+
30
+ # Main app
31
+ def main():
32
+ st.title("🤖 Good evening, Ina Shapiro")
33
+
34
+ # Load agents
35
+ agents = load_agents()
36
+
37
+ # Agent selection
38
+ selected_agent = st.selectbox(
39
+ "Please select an Agent",
40
+ options=list(agents.keys()),
41
+ index=None,
42
+ placeholder="Choose an agent..."
43
+ )
44
+
45
+ if selected_agent:
46
+ st.write(f"Selected: {selected_agent}")
47
+
48
+ # Chat input
49
+ user_input = st.text_input("Ask your question:")
50
+
51
+ if user_input:
52
+ with st.spinner("Agent is thinking..."):
53
+ try:
54
+ agent = agents[selected_agent]
55
+ result = agent.run(user_input)
56
+ st.write("**Agent Response:**")
57
+ st.write(result)
58
+ except Exception as e:
59
+ st.error(f"Error: {str(e)}")
60
+
61
+ if __name__ == "__main__":
62
+ main()