Spaces:
Runtime error
Runtime error
Hugo Garcia-Cotte
commited on
Commit
•
193e7df
1
Parent(s):
88286d0
banging my head on Streamlit
Browse files- app.py +26 -9
- requirements.txt +0 -2
app.py
CHANGED
@@ -1,18 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
import time
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
# start the ttyd server and display the terminal on streamlit
|
8 |
-
ttydprocess, port = terminal(cmd="top")
|
9 |
|
10 |
-
# info on ttyd port
|
11 |
-
st.text(f"ttyd server is running on port : {port}")
|
12 |
|
13 |
-
# kill the ttyd server after a minute
|
14 |
-
time.sleep(60)
|
15 |
-
ttydprocess.kill()
|
16 |
|
17 |
|
18 |
|
|
|
1 |
import streamlit as st
|
2 |
+
import pexpect
|
3 |
import time
|
4 |
|
5 |
+
# Initialize a list of messages
|
6 |
+
# Initialization
|
7 |
+
if 'messages' not in st.session_state:
|
8 |
+
st.session_state['messages'] = []
|
9 |
+
|
10 |
+
if 'child' not in st.session_state:
|
11 |
+
st.session_state['child'] = pexpect.spawn("python danse_macabre.py", encoding='utf-8', timeout=None)
|
12 |
+
|
13 |
+
child = st.session_state['child']
|
14 |
+
|
15 |
+
# Display the list of messages
|
16 |
+
for msg in st.session_state['messages']:
|
17 |
+
st.write(msg)
|
18 |
+
|
19 |
+
child.expect(">>>>>")
|
20 |
+
st.session_state['messages'].append(child.before)
|
21 |
+
|
22 |
+
# Create a text input field for users to enter their messages
|
23 |
+
user_input = st.text_input("Enter your message here:")
|
24 |
+
|
25 |
+
# Add user's message to the list when the submit button is clicked
|
26 |
+
if user_input:
|
27 |
+
st.session_state['messages'].append(user_input)
|
28 |
+
child.sendline(user_input)
|
29 |
+
|
30 |
|
|
|
|
|
31 |
|
|
|
|
|
32 |
|
|
|
|
|
|
|
33 |
|
34 |
|
35 |
|
requirements.txt
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
openai
|
2 |
streamlit
|
3 |
pexpect
|
4 |
-
git+https://github.com/NeveIsa/streamlit_ttyd
|
5 |
-
psutil
|
|
|
1 |
openai
|
2 |
streamlit
|
3 |
pexpect
|
|
|
|