Update app.py
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ def model_response(message, history):
|
|
42 |
print("Format history")
|
43 |
gemini_history = []
|
44 |
|
45 |
-
for
|
46 |
#print(f"t1 {message}")
|
47 |
# Skip thinking messages (messages with metadata)
|
48 |
#if not (message.get("role") == "assistant" and "metadata" in message):
|
@@ -54,15 +54,15 @@ def model_response(message, history):
|
|
54 |
|
55 |
#print(f"t2 {message}")
|
56 |
|
57 |
-
if
|
58 |
gemini_history.append({
|
59 |
"role": "user",
|
60 |
-
"parts": [
|
61 |
})
|
62 |
-
elif
|
63 |
gemini_history.append({
|
64 |
"role": "model",
|
65 |
-
"parts": [
|
66 |
})
|
67 |
|
68 |
print(f"his: {gemini_history}")
|
|
|
42 |
print("Format history")
|
43 |
gemini_history = []
|
44 |
|
45 |
+
for message_to_check in history:
|
46 |
#print(f"t1 {message}")
|
47 |
# Skip thinking messages (messages with metadata)
|
48 |
#if not (message.get("role") == "assistant" and "metadata" in message):
|
|
|
54 |
|
55 |
#print(f"t2 {message}")
|
56 |
|
57 |
+
if message_to_check.get("role") == "user" :
|
58 |
gemini_history.append({
|
59 |
"role": "user",
|
60 |
+
"parts": [message_to_check.get("content", "")]
|
61 |
})
|
62 |
+
elif message_to_check.get("role") == "assistant" :
|
63 |
gemini_history.append({
|
64 |
"role": "model",
|
65 |
+
"parts": [message_to_check.get("content", "")]
|
66 |
})
|
67 |
|
68 |
print(f"his: {gemini_history}")
|