Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -115,12 +115,15 @@ If the user is engaging in discussion, try to steer them towards getting in touc
|
|
115 |
def chat(self, message, history):
|
116 |
messages = [{"role": "system", "content": self.system_prompt()}]
|
117 |
|
118 |
-
#
|
119 |
-
|
120 |
-
messages.
|
121 |
-
|
|
|
|
|
|
|
|
|
122 |
|
123 |
-
# Append the latest user message
|
124 |
messages.append({"role": "user", "content": message})
|
125 |
|
126 |
done = False
|
@@ -139,6 +142,7 @@ If the user is engaging in discussion, try to steer them towards getting in touc
|
|
139 |
done = True
|
140 |
|
141 |
return response.choices[0].message.content
|
|
|
142 |
|
143 |
|
144 |
if __name__ == "__main__":
|
|
|
115 |
def chat(self, message, history):
|
116 |
messages = [{"role": "system", "content": self.system_prompt()}]
|
117 |
|
118 |
+
# Check if history is a list of dicts (Gradio "messages" format)
|
119 |
+
if isinstance(history, list) and all(isinstance(h, dict) for h in history):
|
120 |
+
messages.extend(history)
|
121 |
+
else:
|
122 |
+
# Assume it's a list of [user_msg, assistant_msg] pairs
|
123 |
+
for user_msg, assistant_msg in history:
|
124 |
+
messages.append({"role": "user", "content": user_msg})
|
125 |
+
messages.append({"role": "assistant", "content": assistant_msg})
|
126 |
|
|
|
127 |
messages.append({"role": "user", "content": message})
|
128 |
|
129 |
done = False
|
|
|
142 |
done = True
|
143 |
|
144 |
return response.choices[0].message.content
|
145 |
+
|
146 |
|
147 |
|
148 |
if __name__ == "__main__":
|