Solshine commited on
Commit
f2bd509
โ€ข
1 Parent(s): 8813cc4

Added checkbox for OpenAI integration

Browse files
Files changed (1) hide show
  1. app.py +20 -17
app.py CHANGED
@@ -120,7 +120,7 @@ def launch_bot():
120
  # with st.chat_message("user"):
121
  # st.write("Convert to Audio ๐Ÿ”Š")
122
  text = " :blue[Convert to Audio ] ๐Ÿ”Š "
123
-
124
  with st.expander(text, expanded=False):
125
  sound_file = BytesIO()
126
  tts = gTTS(response, lang='en')
@@ -128,24 +128,27 @@ def launch_bot():
128
 
129
  st.audio(sound_file)
130
 
131
- with #button
132
- with st.chat_message("assistant"):
133
- with st.spinner("Thinking..."):
 
 
 
134
  # Change this to include OpenAI_API key
135
  # Function to get the assistant's response
136
- completion = openai.ChatCompletion.create(
137
- model="gpt-3.5-turbo",
138
- messages=[
139
- {"role": "system", "content": "You are a helpful Natural Farming assistant with extensive experience in accessible science and technical writing, and the heart of a teacher."},
140
- {"role": "user", "content": prompt3}
141
- ]
142
- )
143
-
144
- response = completion.choices[0].message
145
- st.write(response)
146
-
147
- message = {"role": "assistant", "content": response}
148
- st.session_state.messages.append(message)
149
 
150
 
151
  if __name__ == "__main__":
 
120
  # with st.chat_message("user"):
121
  # st.write("Convert to Audio ๐Ÿ”Š")
122
  text = " :blue[Convert to Audio ] ๐Ÿ”Š "
123
+ # Converts Response to Audio
124
  with st.expander(text, expanded=False):
125
  sound_file = BytesIO()
126
  tts = gTTS(response, lang='en')
 
128
 
129
  st.audio(sound_file)
130
 
131
+ agree = st.checkbox('Escalate this response to Premium')
132
+
133
+ if agree:
134
+ Print('OpenAI, Oh Great!')
135
+ with st.chat_message("assistant"):
136
+ with st.spinner("Thinking..."):
137
  # Change this to include OpenAI_API key
138
  # Function to get the assistant's response
139
+ completion = openai.ChatCompletion.create(
140
+ model="gpt-3.5-turbo",
141
+ messages=[
142
+ {"role": "system", "content": "You are a helpful Natural Farming assistant with extensive experience in accessible science and technical writing, and the heart of a teacher."},
143
+ {"role": "user", "content": prompt3}
144
+ ]
145
+ )
146
+
147
+ response = completion.choices[0].message
148
+ st.write(response)
149
+
150
+ message = {"role": "assistant", "content": response}
151
+ st.session_state.messages.append(message)
152
 
153
 
154
  if __name__ == "__main__":