Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,12 +21,6 @@ def main():
|
|
21 |
if 'chat_history' not in st.session_state:
|
22 |
st.session_state['chat_history'] = ''
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
#st.session_state['chat_history'].append("<div style='color: blue;'>You: </div>")
|
28 |
-
#st.session_state['chat_history'].append("<div style='color: red;'>MidikanGPT-4: </div>")
|
29 |
-
|
30 |
# Handle the send button click
|
31 |
if send_button:
|
32 |
# Set the system prompt
|
@@ -41,6 +35,7 @@ def main():
|
|
41 |
# Save 'prompt_1' to the chat history
|
42 |
st.session_state['chat_history'] += "<div style='color: blue;'>You: </div><br><hr style='border: 1px solid black;'>"
|
43 |
st.session_state['chat_history'] += f"{prompt_1}"
|
|
|
44 |
|
45 |
# Hit the OpenAI API with 'prompt_1'
|
46 |
response = openai.ChatCompletion.create(
|
@@ -64,14 +59,18 @@ def main():
|
|
64 |
answers_1 = '\n\n'.join(out_list)
|
65 |
|
66 |
# Save GPT's response to the chat history
|
67 |
-
st.session_state['chat_history']
|
|
|
|
|
68 |
|
69 |
# Prepare 'prompt_2'
|
70 |
prompt_2 = context + '\n\n' + txt_1 + question + '\n\n' + answers_1 + '\n\n' + "You are a researcher tasked with investigating the 3 answer options provided. List the flaws and faulty logic of each answer option. Let's work this out in a step by step way to be sure we have all the errors:"
|
71 |
prompt_2 = prompt_2.strip()
|
72 |
|
73 |
# Save 'prompt_2' to the chat history
|
74 |
-
st.session_state['chat_history']
|
|
|
|
|
75 |
|
76 |
# Hit the OpenAI API with 'prompt_2'
|
77 |
response = openai.ChatCompletion.create(
|
@@ -86,10 +85,17 @@ def main():
|
|
86 |
answers_2 = response['choices'][0]['message']['content']
|
87 |
|
88 |
# Save GPT's response to the chat history
|
89 |
-
st.session_state['chat_history']
|
|
|
|
|
90 |
|
91 |
# Prepare 'prompt_3'
|
92 |
prompt_3 = answers_1 + '\n\n' + answers_2 + '\n\n' + "You are a resolver tasked with 1) finding which of the 3 answer options the researcher thought was best 2) improving that answer, and 3) printing the improved answer in full. Let's work this out in a step by step way to be sure we have the right answer:"
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
# Hit the OpenAI API with 'prompt_3'
|
95 |
response = openai.ChatCompletion.create(
|
@@ -104,12 +110,12 @@ def main():
|
|
104 |
answers_3 = response['choices'][0]['message']['content']
|
105 |
|
106 |
# Save GPT's response to the chat history
|
107 |
-
st.session_state['chat_history']
|
|
|
|
|
108 |
|
109 |
# Creating an area to display the chat history
|
110 |
st.markdown(st.session_state['chat_history'], unsafe_allow_html=True)
|
111 |
-
for message in st.session_state['chat_history']:
|
112 |
-
st.markdown(message)
|
113 |
|
114 |
|
115 |
if __name__ == "__main__":
|
|
|
21 |
if 'chat_history' not in st.session_state:
|
22 |
st.session_state['chat_history'] = ''
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
# Handle the send button click
|
25 |
if send_button:
|
26 |
# Set the system prompt
|
|
|
35 |
# Save 'prompt_1' to the chat history
|
36 |
st.session_state['chat_history'] += "<div style='color: blue;'>You: </div><br><hr style='border: 1px solid black;'>"
|
37 |
st.session_state['chat_history'] += f"{prompt_1}"
|
38 |
+
st.session_state['chat_history'] += "<br><hr style='border: 1px solid black;'>"
|
39 |
|
40 |
# Hit the OpenAI API with 'prompt_1'
|
41 |
response = openai.ChatCompletion.create(
|
|
|
59 |
answers_1 = '\n\n'.join(out_list)
|
60 |
|
61 |
# Save GPT's response to the chat history
|
62 |
+
st.session_state['chat_history'] += "<div style='color: red;'>MidikanGPT-4: </div><br><hr style='border: 1px solid black;'>"
|
63 |
+
st.session_state['chat_history'] += f"{answers_1}"
|
64 |
+
st.session_state['chat_history'] += "<br><hr style='border: 1px solid black;'>"
|
65 |
|
66 |
# Prepare 'prompt_2'
|
67 |
prompt_2 = context + '\n\n' + txt_1 + question + '\n\n' + answers_1 + '\n\n' + "You are a researcher tasked with investigating the 3 answer options provided. List the flaws and faulty logic of each answer option. Let's work this out in a step by step way to be sure we have all the errors:"
|
68 |
prompt_2 = prompt_2.strip()
|
69 |
|
70 |
# Save 'prompt_2' to the chat history
|
71 |
+
st.session_state['chat_history'] += "<div style='color: blue;'>You: </div><br><hr style='border: 1px solid black;'>"
|
72 |
+
st.session_state['chat_history'] += f"{prompt_2}"
|
73 |
+
st.session_state['chat_history'] += "<br><hr style='border: 1px solid black;'>"
|
74 |
|
75 |
# Hit the OpenAI API with 'prompt_2'
|
76 |
response = openai.ChatCompletion.create(
|
|
|
85 |
answers_2 = response['choices'][0]['message']['content']
|
86 |
|
87 |
# Save GPT's response to the chat history
|
88 |
+
st.session_state['chat_history'] += "<div style='color: red;'>MidikanGPT-4: </div><br><hr style='border: 1px solid black;'>"
|
89 |
+
st.session_state['chat_history'] += f"{answers_2}"
|
90 |
+
st.session_state['chat_history'] += "<br><hr style='border: 1px solid black;'>"
|
91 |
|
92 |
# Prepare 'prompt_3'
|
93 |
prompt_3 = answers_1 + '\n\n' + answers_2 + '\n\n' + "You are a resolver tasked with 1) finding which of the 3 answer options the researcher thought was best 2) improving that answer, and 3) printing the improved answer in full. Let's work this out in a step by step way to be sure we have the right answer:"
|
94 |
+
|
95 |
+
# Save the end of 'prompt_3' to the chat history
|
96 |
+
st.session_state['chat_history'] += "<div style='color: blue;'>You: </div><br><hr style='border: 1px solid black;'>"
|
97 |
+
st.session_state['chat_history'] += "You are a resolver tasked with 1) finding which of the 3 answer options the researcher thought was best 2) improving that answer, and 3) printing the improved answer in full. Let's work this out in a step by step way to be sure we have the right answer:"
|
98 |
+
st.session_state['chat_history'] += "<br><hr style='border: 1px solid black;'>"
|
99 |
|
100 |
# Hit the OpenAI API with 'prompt_3'
|
101 |
response = openai.ChatCompletion.create(
|
|
|
110 |
answers_3 = response['choices'][0]['message']['content']
|
111 |
|
112 |
# Save GPT's response to the chat history
|
113 |
+
st.session_state['chat_history'] += "<div style='color: red;'>MidikanGPT-4: </div><br><hr style='border: 1px solid black;'>"
|
114 |
+
st.session_state['chat_history'] += f"{answers_3}"
|
115 |
+
st.session_state['chat_history'] += "<br><hr style='border: 1px solid black;'>"
|
116 |
|
117 |
# Creating an area to display the chat history
|
118 |
st.markdown(st.session_state['chat_history'], unsafe_allow_html=True)
|
|
|
|
|
119 |
|
120 |
|
121 |
if __name__ == "__main__":
|