Solshine commited on
Commit
aaba81b
1 Parent(s): 7211408

Works and modifying. The voice from response works now. Adding other LLM tag-in

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -6,6 +6,8 @@ import os
6
  from transformers import pipeline
7
  import numpy as np
8
  import tempfile
 
 
9
 
10
  import streamlit as st
11
  from PIL import Image
@@ -125,8 +127,25 @@ def launch_bot():
125
  tts.write_to_fp(sound_file)
126
 
127
  st.audio(sound_file)
128
-
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
 
132
  if __name__ == "__main__":
 
6
  from transformers import pipeline
7
  import numpy as np
8
  import tempfile
9
+ import os
10
+ import openai
11
 
12
  import streamlit as st
13
  from PIL import Image
 
127
  tts.write_to_fp(sound_file)
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__":