Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,8 @@ def chat_with_model(prompt, document_section):
|
|
33 |
model = model_choice
|
34 |
conversation = [{'role': 'system', 'content': 'You are a helpful assistant.'}]
|
35 |
conversation.append({'role': 'user', 'content': prompt})
|
36 |
-
|
|
|
37 |
response = openai.ChatCompletion.create(model=model, messages=conversation)
|
38 |
return response['choices'][0]['message']['content']
|
39 |
|
@@ -69,10 +70,11 @@ def save_and_play_audio(audio_recorder):
|
|
69 |
|
70 |
filename = save_and_play_audio(audio_recorder)
|
71 |
if filename is not None:
|
72 |
-
if st.button("Transcribe"):
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
76 |
|
77 |
def create_file(filename, prompt, response):
|
78 |
if filename.endswith(".txt"):
|
|
|
33 |
model = model_choice
|
34 |
conversation = [{'role': 'system', 'content': 'You are a helpful assistant.'}]
|
35 |
conversation.append({'role': 'user', 'content': prompt})
|
36 |
+
if len(document_section)>0:
|
37 |
+
conversation.append({'role': 'assistant', 'content': document_section})
|
38 |
response = openai.ChatCompletion.create(model=model, messages=conversation)
|
39 |
return response['choices'][0]['message']['content']
|
40 |
|
|
|
70 |
|
71 |
filename = save_and_play_audio(audio_recorder)
|
72 |
if filename is not None:
|
73 |
+
#if st.button("Transcribe"):
|
74 |
+
|
75 |
+
transcription = transcribe_audio(openai.api_key, filename, "whisper-1")
|
76 |
+
st.write(transcription)
|
77 |
+
chat_with_model(transcription, '') # push transcript through as prompt
|
78 |
|
79 |
def create_file(filename, prompt, response):
|
80 |
if filename.endswith(".txt"):
|