logicaldata commited on
Commit
04ebcf7
·
1 Parent(s): 5300979

Add basic agent interface

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ ECHO is on.
3
+ "# Initialize session state"
4
+ 'if "messages" not in st.session_state:'
5
+ ECHO is on.
6
+ "# Sidebar for agent configuration"
7
+ ' st.header("?? Agent Settings")'
8
+ ' agent_name = st.text_input("Name your agent", "AI Assistant")'
9
+ ' temperature = st.slider("Creativity", 0.0, 1.0, 0.5)'
10
+ ECHO is on.
11
+ "# Main chat interface"
12
+ 'st.title(f"?? {agent_name}")'
13
+ ECHO is on.
14
+ "# Display chat history"
15
+ 'for message in st.session_state.messages:'
16
+ ' with st.chat_message(message["role"]):'
17
+ ' st.write(message["content"])'
18
+ ECHO is on.
19
+ "# Handle user input"
20
+ 'if prompt := st.chat_input("Say something"):'
21
+ ' # Add user message to history'
22
+ ' st.session_state.messages.append({"role": "user", "content": prompt})'
23
+ ECHO is on.
24
+ ' # Generate a simple response'
25
+ ' response = f"{agent_name}: I'\''m thinking about '\''{prompt}'\'' (Temp: {temperature})"'
26
+ ECHO is on.
27
+ ' # Add AI response'
28
+ ' st.session_state.messages.append({"role": "assistant", "content": response})'