Skip to content

Conversation

@NTLx
Copy link
Contributor

@NTLx NTLx commented Jan 31, 2026

This PR adds full support for importing and exporting memories, addressing Issue #137.

This contribution is part of the OceanBase AI Coding Event.

🚀 Features

  • Export: Export memories to JSON (full data) or CSV (spreadsheet compatible).
  • Import: Bulk import memories from JSON or CSV files.
  • API Support: New endpoints GET /v1/memories/export and POST /v1/memories/import.

🛠 Implementation

  • Utils: Created src/powermem/utils/io.py for robust serialization logic.
  • Core: Updated Memory class with export_memories and import_memories methods.
  • API: Added streaming response for exports and file upload for imports.

✅ AI Contribution Details

  • Design: Implemented a layered architecture (Utils -> Core -> API) for maintainability.
  • Formats: Chose JSON for fidelity and CSV for accessibility.
  • Performance: Used streaming for large exports.

@Teingi
Copy link
Member

Teingi commented Jan 31, 2026

There are merge conflicts in this pull request. Please resolve them before we can proceed with the review.

@NTLx
Copy link
Contributor Author

NTLx commented Jan 31, 2026

Hi @Teingi, I have resolved the merge conflicts by merging the latest main branch into this feature branch. Please take another look when you have time. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is recommended to remove it from the formal PR.

NTLx added a commit to NTLx/powermem that referenced this pull request Feb 9, 2026
- Keep PR oceanbase#213 import/export features
- Keep upstream/main set_timezone import

Conflict resolved in src/powermem/core/memory.py
@NTLx
Copy link
Contributor Author

NTLx commented Feb 10, 2026

Hi @Teingi! I've resolved the merge conflicts with the latest upstream/main branch.

Conflict resolved:

  • Merged set_timezone import from upstream/main
  • Kept import/export functionality from this PR

Please re-trigger CI to verify. Thanks!

@Teingi
Copy link
Member

Teingi commented Feb 10, 2026

Hi @Teingi! I've resolved the merge conflicts with the latest upstream/main branch.

Conflict resolved:

  • Merged set_timezone import from upstream/main
  • Kept import/export functionality from this PR

Please re-trigger CI to verify. Thanks!

Were the changes not committed?

@Teingi
Copy link
Member

Teingi commented Feb 10, 2026

image image


self.agent_id = agent_id

# Set timezone from config if provided (priority: config > env)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've modified some code that isn't related to this feature.

# Merge custom_importance_evaluation_prompt from top level if present
if self.memory_config.custom_importance_evaluation_prompt:
cfg["custom_importance_evaluation_prompt"] = self.memory_config.custom_importance_evaluation_prompt
# Merge memory_decay config if present (for Ebbinghaus algorithm parameters)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on the main logic, but these extra changes might belong elsewhere.

- "relations" (List, optional): Graph relations if graph store is enabled
"""
try:
if not query or not query.strip():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

filters=filters,
limit=limit,
query=query, # Pass query text for hybrid search (vector + full-text + sparse vector)
threshold=threshold, # Pass threshold to storage for native hybrid search condition check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

for mem_id, upd in updates:
_BACKGROUND_EXECUTOR.submit(self.storage.update_memory,mem_id,{**upd},user_id,agent_id)
logger.info(f"Submitted {len(updates)} update operations to background executor")
if deletes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

for mem_id, upd in updates:
try:
self.storage.update_memory(mem_id, {**upd}, user_id, agent_id)
except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

strategy: "deduplicate" or "compress"
**kwargs: Additional args like threshold, user_id, dedup_strategy

Returns:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@NTLx
Copy link
Contributor Author

NTLx commented Feb 11, 2026

Replaced with clean PR to fix unrelated code changes

@NTLx NTLx closed this Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants