Spaces:
Running
Running
Commit ·
3e394af
1
Parent(s): 093c145
fixed memories
Browse files- src/manager/manager.py +15 -6
src/manager/manager.py
CHANGED
|
@@ -172,18 +172,28 @@ class GeminiManager:
|
|
| 172 |
if isinstance(message["content"], tuple):
|
| 173 |
path = message["content"][0]
|
| 174 |
try:
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
except Exception as e:
|
| 178 |
logger.error(f"Error uploading file: {e}")
|
| 179 |
-
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
continue
|
| 182 |
else:
|
| 183 |
parts = [types.Part.from_text(
|
| 184 |
text=message.get("content", ""))]
|
| 185 |
case "memories":
|
| 186 |
-
role = "
|
| 187 |
parts = [types.Part.from_text(
|
| 188 |
text="Relevant memories: "+message.get("content", ""))]
|
| 189 |
case "tool":
|
|
@@ -193,7 +203,6 @@ class GeminiManager:
|
|
| 193 |
continue
|
| 194 |
case "function_call":
|
| 195 |
role = "model"
|
| 196 |
-
print(message)
|
| 197 |
formatted_history.append(
|
| 198 |
eval(message.get("content", "")))
|
| 199 |
continue
|
|
|
|
| 172 |
if isinstance(message["content"], tuple):
|
| 173 |
path = message["content"][0]
|
| 174 |
try:
|
| 175 |
+
image_bytes = open(path, "rb").read()
|
| 176 |
+
parts = [
|
| 177 |
+
types.Part.from_bytes(
|
| 178 |
+
data=image_bytes,
|
| 179 |
+
mime_type="image/png",
|
| 180 |
+
),
|
| 181 |
+
]
|
| 182 |
except Exception as e:
|
| 183 |
logger.error(f"Error uploading file: {e}")
|
| 184 |
+
parts = [types.Part.from_text(
|
| 185 |
+
text="Error uploading file: "+str(e))]
|
| 186 |
+
formatted_history.append(
|
| 187 |
+
types.Content(
|
| 188 |
+
role=role,
|
| 189 |
+
parts=parts
|
| 190 |
+
))
|
| 191 |
continue
|
| 192 |
else:
|
| 193 |
parts = [types.Part.from_text(
|
| 194 |
text=message.get("content", ""))]
|
| 195 |
case "memories":
|
| 196 |
+
role = "model"
|
| 197 |
parts = [types.Part.from_text(
|
| 198 |
text="Relevant memories: "+message.get("content", ""))]
|
| 199 |
case "tool":
|
|
|
|
| 203 |
continue
|
| 204 |
case "function_call":
|
| 205 |
role = "model"
|
|
|
|
| 206 |
formatted_history.append(
|
| 207 |
eval(message.get("content", "")))
|
| 208 |
continue
|