Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,15 +5,35 @@ import streamlit as st
|
|
5 |
openai.api_key = st.secrets['OpenAI_API_Key']
|
6 |
|
7 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# Creating a sidebar for user inputs
|
9 |
-
st.sidebar.title("Chat
|
10 |
|
11 |
# Creating a text input field for user question context
|
12 |
-
context = st.sidebar.text_input("
|
13 |
|
14 |
# Creating a text input field for user questions
|
15 |
-
question = st.sidebar.text_input("Type your question:")
|
|
|
16 |
|
|
|
17 |
# Creating a button for the user to send their message
|
18 |
send_button = st.sidebar.button("Send")
|
19 |
|
@@ -33,7 +53,8 @@ def main():
|
|
33 |
prompt_1 = prompt_1.strip()
|
34 |
|
35 |
# Save 'prompt_1' to the chat history
|
36 |
-
st.session_state['chat_history'].append(f"You: {prompt_1}")
|
|
|
37 |
|
38 |
# Hit the OpenAI API with 'prompt_1'
|
39 |
response = openai.ChatCompletion.create(
|
@@ -57,8 +78,8 @@ def main():
|
|
57 |
answers_1 = '\n\n'.join(out_list)
|
58 |
|
59 |
# Save GPT's response to the chat history
|
60 |
-
st.session_state['chat_history'].append(f"
|
61 |
-
|
62 |
# Prepare 'prompt_2'
|
63 |
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:"
|
64 |
prompt_2 = prompt_2.strip()
|
@@ -77,8 +98,6 @@ def main():
|
|
77 |
)
|
78 |
|
79 |
answers_2 = response['choices'][0]['message']['content']
|
80 |
-
print(type(answers_2))
|
81 |
-
print(answers_2)
|
82 |
|
83 |
# Save GPT's response to the chat history
|
84 |
st.session_state['chat_history'].append(f"SmartGPT-4: {answers_2}")
|
|
|
5 |
openai.api_key = st.secrets['OpenAI_API_Key']
|
6 |
|
7 |
def main():
|
8 |
+
# Inject custom CSS
|
9 |
+
st.markdown("""
|
10 |
+
<style>
|
11 |
+
.reportview-container {
|
12 |
+
background: #f4f4f4; # Change the background color
|
13 |
+
}
|
14 |
+
.sidebar .sidebar-content {
|
15 |
+
background: #ffffff; # Change the sidebar background color
|
16 |
+
}
|
17 |
+
h1 {
|
18 |
+
color: #ff6347; # Change the color of the title
|
19 |
+
}
|
20 |
+
</style>
|
21 |
+
""", unsafe_allow_html=True)
|
22 |
+
|
23 |
+
# Use markdown for the title with a custom color
|
24 |
+
st.sidebar.markdown("<h1 style='color: #ff6347;'>Chat w/MidikanGPT-4</h1>", unsafe_allow_html=True)
|
25 |
+
|
26 |
# Creating a sidebar for user inputs
|
27 |
+
#st.sidebar.title("Chat w/MidikanGPT-4")
|
28 |
|
29 |
# Creating a text input field for user question context
|
30 |
+
context = st.sidebar.text_input("Context, if any:")
|
31 |
|
32 |
# Creating a text input field for user questions
|
33 |
+
#question = st.sidebar.text_input("Type your question/command:")
|
34 |
+
question = st.sidebar.text_area("Question/command:")
|
35 |
|
36 |
+
|
37 |
# Creating a button for the user to send their message
|
38 |
send_button = st.sidebar.button("Send")
|
39 |
|
|
|
53 |
prompt_1 = prompt_1.strip()
|
54 |
|
55 |
# Save 'prompt_1' to the chat history
|
56 |
+
#st.session_state['chat_history'].append(f"You: {prompt_1}")
|
57 |
+
st.session_state['chat_history'].append(f"<div style='color: blue;'>You: {prompt_1}</div>")
|
58 |
|
59 |
# Hit the OpenAI API with 'prompt_1'
|
60 |
response = openai.ChatCompletion.create(
|
|
|
78 |
answers_1 = '\n\n'.join(out_list)
|
79 |
|
80 |
# Save GPT's response to the chat history
|
81 |
+
st.session_state['chat_history'].append(f"<div style='color: red;'>MidikanGPT-4: {answers_1}</div>")
|
82 |
+
|
83 |
# Prepare 'prompt_2'
|
84 |
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:"
|
85 |
prompt_2 = prompt_2.strip()
|
|
|
98 |
)
|
99 |
|
100 |
answers_2 = response['choices'][0]['message']['content']
|
|
|
|
|
101 |
|
102 |
# Save GPT's response to the chat history
|
103 |
st.session_state['chat_history'].append(f"SmartGPT-4: {answers_2}")
|