Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,7 @@ model = openai.api_key = os.environ["OPENAI_API_KEY"]
|
|
18 |
# Define the initial message and messages list
|
19 |
initial_message = {"role": "system", "content": 'You are a USMLE Tutor. Respond with ALWAYS layered "bullet points" (listing rather than sentences) to all input with a fun mneumonics to memorize that list. But you can answer up to 1200 words if the user requests longer response.'}
|
20 |
messages = [initial_message]
|
|
|
21 |
|
22 |
# Define the answer counter
|
23 |
answer_count = 0
|
@@ -100,6 +101,12 @@ def transcribe(audio, text):
|
|
100 |
|
101 |
# Add the system message to the messages list
|
102 |
messages.append(system_message)
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
# Concatenate the chat history
|
105 |
chat_transcript = "\n\n".join([f"[ANSWER {answer_count}]{message['role']}: {message['content']}" for message in messages if message['role'] != 'system'])
|
|
|
18 |
# Define the initial message and messages list
|
19 |
initial_message = {"role": "system", "content": 'You are a USMLE Tutor. Respond with ALWAYS layered "bullet points" (listing rather than sentences) to all input with a fun mneumonics to memorize that list. But you can answer up to 1200 words if the user requests longer response.'}
|
20 |
messages = [initial_message]
|
21 |
+
messages_rev = [initial_message]
|
22 |
|
23 |
# Define the answer counter
|
24 |
answer_count = 0
|
|
|
101 |
|
102 |
# Add the system message to the messages list
|
103 |
messages.append(system_message)
|
104 |
+
|
105 |
+
# Add the system message to the beginning of the messages list
|
106 |
+
messages_rev.insert(0, system_message)
|
107 |
+
# Add the input text to the messages list
|
108 |
+
messages_rev.insert(0, {"role": "user", "content": input_text + transcript["text"]})
|
109 |
+
|
110 |
|
111 |
# Concatenate the chat history
|
112 |
chat_transcript = "\n\n".join([f"[ANSWER {answer_count}]{message['role']}: {message['content']}" for message in messages if message['role'] != 'system'])
|