Update app.py
Browse files
app.py
CHANGED
|
@@ -62,7 +62,7 @@ def transcribe(audio, text):
|
|
| 62 |
input_text = tokenizer.decode(input_tokens)
|
| 63 |
|
| 64 |
# Add the input text to the messages list
|
| 65 |
-
messages.append({"role": "user", "content": transcript["text"]+input_text})
|
| 66 |
|
| 67 |
|
| 68 |
# Check if the accumulated tokens have exceeded 2096
|
|
@@ -104,7 +104,13 @@ def transcribe(audio, text):
|
|
| 104 |
# Wait for the completion of the OpenAI API call
|
| 105 |
|
| 106 |
# Add the system message to the messages list
|
| 107 |
-
messages.append(system_message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
# Concatenate the chat history
|
| 110 |
chat_transcript = "\n\n".join([f"[ANSWER {answer_count}]{message['role']}: {message['content']}" for message in messages if message['role'] != 'system'])
|
|
|
|
| 62 |
input_text = tokenizer.decode(input_tokens)
|
| 63 |
|
| 64 |
# Add the input text to the messages list
|
| 65 |
+
# messages.append({"role": "user", "content": transcript["text"]+input_text})
|
| 66 |
|
| 67 |
|
| 68 |
# Check if the accumulated tokens have exceeded 2096
|
|
|
|
| 104 |
# Wait for the completion of the OpenAI API call
|
| 105 |
|
| 106 |
# Add the system message to the messages list
|
| 107 |
+
# messages.append(system_message)
|
| 108 |
+
|
| 109 |
+
# Add the system message to the beginning of the messages list
|
| 110 |
+
messages.insert(0, system_message)
|
| 111 |
+
# Add the input text to the messages list
|
| 112 |
+
messages.insert(0, {"role": "user", "content": input_text + transcript["text"]})
|
| 113 |
+
|
| 114 |
|
| 115 |
# Concatenate the chat history
|
| 116 |
chat_transcript = "\n\n".join([f"[ANSWER {answer_count}]{message['role']}: {message['content']}" for message in messages if message['role'] != 'system'])
|