You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EXTRACTION_PROMPT_PART_1=f"""You are a memory extractor. Your task is to extract memories from the given messages.
211
-
* You will receive a list of messages, each with a role (user or assistant) and content.
212
-
* Your job is to extract memories related to the user's long-term goals, interests, and emotional states.
213
-
* Each memory should be a dictionary with the following keys:
214
-
- "memory": The content of the memory (string). Rephrase the content if necessary.
215
-
- "metadata": A dictionary containing additional information about the memory.
216
-
* The metadata dictionary should include:
217
-
- "type": The type of memory (string), e.g., "procedure", "fact", "event", "opinion", etc.
218
-
- "memory_time": The time the memory occurred or refers to (string). Must be in standard `YYYY-MM-DD` format. Relative expressions such as "yesterday" or "tomorrow" are not allowed.
219
-
- "source": The origin of the memory (string), e.g., `"conversation"`, `"retrieved"`, `"web"`, `"file"`.
220
-
- "confidence": A numeric score (float between 0 and 100) indicating how certain you are about the accuracy or reliability of the memory.
221
-
- "entities": A list of key entities (array of strings) mentioned in the memory, e.g., people, places, organizations, e.g., `["Alice", "Paris", "OpenAI"]`.
222
-
- "tags": A list of keywords or thematic labels (array of strings) associated with the memory for categorization or retrieval, e.g., `["travel", "health", "project-x"]`.
223
-
- "visibility": The accessibility scope of the memory (string), e.g., `"private"`, `"public"`, `"session"`, determining who or what contexts can access it.
224
-
- "updated_at": The timestamp of the last modification to the memory (string). Useful for tracking memory freshness or change history. Format: ISO 8601 or natural language.
225
-
* Current date and time is {datetime.now().isoformat()}.
226
-
* Only return the list of memories in JSON format.
227
-
* Do not include any explanations
228
-
* Do not include any extra text
229
-
* Do not include code blocks (```json```)
230
-
231
-
## Example
232
-
233
-
### Input
234
-
235
-
[
236
-
{{"role": "user", "content": "I plan to visit Paris next week."}},
237
-
{{"role": "assistant", "content": "Paris is a beautiful city with many attractions."}},
238
-
{{"role": "user", "content": "I love the Eiffel Tower."}},
239
-
{{"role": "assistant", "content": "The Eiffel Tower is a must-see landmark in Paris."}}
240
-
]
241
-
242
-
### Output
243
-
244
-
[
245
-
{{
246
-
"memory": "The user plans to visit Paris on 05-26-2025.",
247
-
"metadata": {{
248
-
"type": "event",
249
-
"memory_time": "2025-05-26",
250
-
"source": "conversation",
251
-
"confidence": 90.0,
252
-
"entities": ["Paris"],
253
-
"tags": ["travel", "plans"],
254
-
"visibility": "private",
255
-
"updated_at": "2025-05-19T00:00:00"
256
-
}}
257
-
}},
258
-
{{
259
-
"memory": "The user loves the Eiffel Tower.",
260
-
"metadata": {{
261
-
"type": "opinion",
262
-
"memory_time": "2025-05-19",
263
-
"source": "conversation",
264
-
"confidence": 100.0,
265
-
"entities": ["Eiffel Tower"],
266
-
"tags": ["opinions", "landmarks"],
267
-
"visibility": "session",
268
-
"updated_at": "2025-05-19T00:00:00"
269
-
}}
270
-
}}
271
-
]
272
-
273
-
"""
274
-
275
-
EXTRACTION_PROMPT_PART_2="""
276
-
## Query
277
-
278
-
### Input
279
-
280
-
{messages}
281
-
282
-
### Output
283
-
284
-
"""
285
-
286
-
EXTRACTION_RETRY_LOG="""Extracting memory failed due to JSON decode error: {error},
description='The time the memory occurred or refers to. Must be in standard `YYYY-MM-DD` format. Relative expressions such as "yesterday" or "tomorrow" are not allowed.',
0 commit comments