Spaces:
Runtime error
Runtime error
Hugo Garcia-Cotte
commited on
Commit
•
9d642e3
1
Parent(s):
3b5261c
Used pexpect to spawn child process
Browse files- app.py +30 -22
- danse_macabre.py +2 -1
app.py
CHANGED
@@ -1,33 +1,41 @@
|
|
1 |
import streamlit as st
|
2 |
-
import subprocess
|
3 |
|
4 |
-
# Create
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
stdout=subprocess.PIPE,
|
12 |
-
stderr=subprocess.PIPE)
|
13 |
|
|
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
def write(process, message):
|
20 |
-
process.stdin.write(f"{message.strip()}\n".encode("utf-8"))
|
21 |
-
process.stdin.flush()
|
22 |
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
process.terminate()
|
27 |
-
process.wait(timeout=0.2)
|
28 |
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
+
# Create a list to hold messages
|
4 |
+
messages = []
|
5 |
|
6 |
+
# Define a function to handle form submissions
|
7 |
+
def handle_form_submit(form_data):
|
8 |
+
message = form_data["message"]
|
9 |
+
messages.append(message)
|
|
|
|
|
10 |
|
11 |
+
# Define the layout of the app
|
12 |
+
st.title("Scrollable Output and Submitable Form")
|
13 |
+
st.write("Enter a message below and click 'Submit' to add it to the output:")
|
14 |
|
15 |
+
# Add the input form
|
16 |
+
form = st.form(key="message_form")
|
17 |
+
message_input = form.text_input(label="Message:")
|
18 |
+
submit_button = form.form_submit_button(label="Submit", on_click=handle_form_submit, args=(form_data,))
|
19 |
+
st.write("")
|
20 |
|
21 |
+
# Add the output window
|
22 |
+
if len(messages) > 0:
|
23 |
+
st.write("Output:")
|
24 |
+
with st.beta_container():
|
25 |
+
for message in messages:
|
26 |
+
st.write("- " + message)
|
27 |
+
else:
|
28 |
+
st.write("No messages yet.")
|
29 |
|
|
|
|
|
|
|
30 |
|
31 |
|
32 |
+
"""import pexpect
|
33 |
+
import time
|
|
|
|
|
34 |
|
35 |
+
# Start the other program
|
36 |
+
child = pexpect.spawn("python DO_NOT_COMMIT.py", encoding='utf-8', timeout=None)
|
37 |
|
38 |
+
while True:
|
39 |
+
child.expect(">>>>>")
|
40 |
+
print(child.before)
|
41 |
+
child.sendline(input(">>>>>"))"""
|
danse_macabre.py
CHANGED
@@ -429,7 +429,8 @@ def sequence(sequencePrompt,sequenceIntro,controlPrompt,secondaryControlPrompt=N
|
|
429 |
|
430 |
while True:
|
431 |
|
432 |
-
|
|
|
433 |
|
434 |
#Let's clean the prompt for non conversational characters
|
435 |
prompt = re.sub(r'[^\w\s\'!\(\)\?\.\,\:\;\-]', '', prompt)
|
|
|
429 |
|
430 |
while True:
|
431 |
|
432 |
+
print(">>>>>")
|
433 |
+
prompt = input()
|
434 |
|
435 |
#Let's clean the prompt for non conversational characters
|
436 |
prompt = re.sub(r'[^\w\s\'!\(\)\?\.\,\:\;\-]', '', prompt)
|