Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -143,38 +143,38 @@ def respond_tutor(message, history, mom_type):
|
|
143 |
f"Question{message}"
|
144 |
)}]
|
145 |
|
146 |
-
|
147 |
-
|
148 |
|
149 |
-
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
)
|
155 |
-
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
|
161 |
-
|
162 |
-
|
163 |
"content": (
|
164 |
f"Context:\n{top_strict_results}\n\n"
|
165 |
f"Question{message}"
|
166 |
)}]
|
167 |
|
168 |
-
|
169 |
-
|
170 |
|
171 |
-
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
)
|
177 |
-
|
178 |
|
179 |
with gr.Blocks() as chatbot:
|
180 |
|
|
|
143 |
f"Question{message}"
|
144 |
)}]
|
145 |
|
146 |
+
if history:
|
147 |
+
messages.extend(history)
|
148 |
|
149 |
+
messages.append({"role": "user", "content": message})
|
150 |
|
151 |
+
response = client.chat_completion(
|
152 |
+
messages,
|
153 |
+
temperature = 0.2
|
154 |
)
|
155 |
+
return response['choices'][0]['message']['content'].strip()
|
156 |
|
157 |
+
def respond_strict(message, history):
|
158 |
+
top_strict_results = get_top_chunks(message, strict_chunk_embeddings, cleaned_strict_chunks)
|
159 |
+
#str_chunks = "\n".join(best_chunks)
|
160 |
|
161 |
+
messages = [{"role": "system", "content": f"You are chatbot that plays the role of the user's extremely strict mom. Respond in full sentences, don't cut yourself off. Base your response on the provided context: {top_strict_results}"},
|
162 |
+
{"role": "user",
|
163 |
"content": (
|
164 |
f"Context:\n{top_strict_results}\n\n"
|
165 |
f"Question{message}"
|
166 |
)}]
|
167 |
|
168 |
+
if history:
|
169 |
+
messages.extend(history)
|
170 |
|
171 |
+
messages.append({"role": "user", "content": message})
|
172 |
|
173 |
+
response = client.chat_completion(
|
174 |
+
messages,
|
175 |
+
temperature = 0.2
|
176 |
)
|
177 |
+
return response['choices'][0]['message']['content'].strip()
|
178 |
|
179 |
with gr.Blocks() as chatbot:
|
180 |
|