Spaces:
Runtime error
Runtime error
Hugo Garcia-Cotte
commited on
Commit
•
8a7e1d1
1
Parent(s):
a7a08cf
Add first version of the game file
Browse files
app.py
CHANGED
@@ -1,57 +1,30 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
-
import openai
|
4 |
import streamlit as st
|
5 |
-
|
6 |
-
|
7 |
-
st.set_page_config(
|
8 |
-
page_title="ChatGPT",
|
9 |
-
page_icon=":robot:"
|
10 |
-
)
|
11 |
-
|
12 |
-
st.header("ChatGPT")
|
13 |
-
|
14 |
-
if 'generated' not in st.session_state:
|
15 |
-
st.session_state['generated'] = []
|
16 |
-
if 'past' not in st.session_state:
|
17 |
-
st.session_state['past'] = []
|
18 |
-
if 'messages' not in st.session_state:
|
19 |
-
st.session_state['messages'] = [
|
20 |
-
{"role": "system", "content": "You are a helpful assistant that translates English to Chinese."}]
|
21 |
-
|
22 |
|
23 |
-
|
24 |
-
st.session_state['messages'].append({"role": "user", "content": question})
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
model="gpt-3.5-turbo",
|
29 |
-
temperature=1.2,
|
30 |
-
messages=st.session_state['messages'],
|
31 |
-
max_tokens=2000
|
32 |
-
)
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
return answer
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
#
|
41 |
-
|
42 |
-
|
43 |
-
# Every form must have a submit button.
|
44 |
-
# c1, c2 = st.columns([2, 2])
|
45 |
-
submitted = st.form_submit_button("🤖 Submit")
|
46 |
-
|
47 |
-
if submitted and input_text:
|
48 |
-
output = query(input_text, )
|
49 |
if output:
|
50 |
-
st.
|
51 |
-
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
|
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
st.title("Command-line interface")
|
|
|
5 |
|
6 |
+
# Define the command to be executed
|
7 |
+
cmd = ["python", "danse_macabre.py"]
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# Create a subprocess object
|
10 |
+
process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
|
|
11 |
|
12 |
+
# Loop until the Python program exits
|
13 |
+
while process.poll() is None:
|
14 |
+
# Check if the program has output
|
15 |
+
output = process.stdout.readline()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
if output:
|
17 |
+
st.text(output.strip())
|
18 |
+
|
19 |
+
# Check if the program has an error
|
20 |
+
error = process.stderr.readline()
|
21 |
+
if error:
|
22 |
+
st.error(error.strip())
|
23 |
|
24 |
+
# Get user input using a Streamlit text_input component
|
25 |
+
user_input = st.text_input("Input", "")
|
26 |
|
27 |
+
# Pass user input to the Python program
|
28 |
+
if user_input:
|
29 |
+
process.stdin.write(user_input + "\n")
|
30 |
+
process.stdin.flush()
|