Skip to content

Feat: neo4j community #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 21, 2025
Merged

Feat: neo4j community #121

merged 15 commits into from
Jul 21, 2025

Conversation

CaralHsi
Copy link
Collaborator

@CaralHsi CaralHsi commented Jul 17, 2025

Description

Summary:
feat: support Neo4j Community Edition with Qdrant integration

  • Introduced Neo4jCommunityGraphDB and Neo4jCommunityGraphDBConfig for Community Edition compatibility
    • Disabled enterprise-only features: multi-database, vector index, DB creation/drop
    • Enforced per-user isolation via mandatory user_name
  • Integrated external vector DB (Qdrant) for embedding storage and retrieval
    • Implemented get_by_ids and ensure_payload_indexes in base VecDB interface
  • Updated factories (GraphDBConfigFactory, GraphStoreFactory) to support neo4j-community backend
  • Added tree_config_community.json as an example config using Neo4j Community + Qdrant
  • Added quickstart script simple_openapi_memos_neo4j_community.py to demonstrate core functionality:
    • Memory add/get/search
    • OpenAI chat integration
    • Embedding filtering in display
  • Refactored node parsing for subclass extensibility
  • Cleaned up legacy code: removed unused comments and fixed edge deletion/property bugs

This change enables full MemOS support for open-source Neo4j deployments, expanding accessibility and ease of adoption.

Fix: #95

Reviewer: @(reviewer)

Checklist:

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have added necessary documentation (if applicable) | 我已添加必要的文档(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

@CaralHsi CaralHsi changed the base branch from main to dev July 17, 2025 13:26
@CaralHsi CaralHsi self-assigned this Jul 19, 2025
@CaralHsi CaralHsi marked this pull request as ready for review July 21, 2025 04:09
@CaralHsi CaralHsi requested a review from fridayL July 21, 2025 09:08
Copy link
Collaborator

@fridayL fridayL left a comment

Choose a reason for hiding this comment

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

Code Review & Summary for PR #121 – Neo4j Community Edition Support

1. Neo4j Community Edition Support

  • New Classes & Configs

    • Neo4jCommunityGraphDB and Neo4jCommunityGraphDBConfig are introduced.
    • These provide Neo4j Community Edition compatibility by disabling multi-database and vector index features (which are enterprise-only).
  • User Isolation & Vector Database

    • Enforces per-user isolation via a mandatory user_name field.
    • Embeddings are handled by an external vector database (Qdrant), not Neo4j itself.
  • Indexing

    • Only creates basic B-tree property indexes on Neo4j.
    • Vector payload indexes are managed in Qdrant.
  • Unsupported Operations

    • Multi-DB, DB creation, and destructive DB drop operations are explicitly disallowed or raise clear errors.

2. Factory and Configuration Updates

  • Factory Methods
    • Both GraphDBConfigFactory and GraphStoreFactory are updated to support the "neo4j-community" backend.
  • Example Configuration
    • A sample config file (tree_config_community.json) is added showing how to use Neo4j Community with Qdrant for vectors.

3. Example Scripts

  • Quickstart Example
    • simple_openapi_memos_neo4j_community.py: Shows how to set up MOS with OpenAI API, Neo4j Community, and Qdrant.
    • Demonstrates memory add/get/search, conversation, and filtering out embeddings from display results.

4. Vector DB Abstraction & Qdrant

  • Interface Expansion
    • get_by_ids and ensure_payload_indexes are now abstract methods in the base vector DB interface.
    • Qdrant backend implements these, allowing multi-id fetches and idempotent payload index creation.

5. Code Quality and Minor Changes

  • Refactoring
    • Node parsing logic is moved to instance methods for subclass extensibility.
    • Unused debug and Chinese comments are removed.
  • Bug Fixes
    • Fixes around node parsing, edge deletion, and property handling.

Summary

This PR enables MemOS to use Neo4j Community Edition as a graph backend by:

  • Separating enterprise-specific logic,
  • Integrating Qdrant for vector search,
  • Enforcing per-user logical isolation,
  • Providing clear example usage and configuration.

Impact:
Greatly broadens deployability—users can now run MemOS with open-source Neo4j and Qdrant, no enterprise license needed.

Code Quality:
Code is modular and maintainable, with good extensibility for future data backends.

Overall:
A significant improvement for open-source and multi-tenant deployments. Well-structured, well-documented, and easy to adopt.

@CaralHsi CaralHsi merged commit 956a9d7 into MemTensor:dev Jul 21, 2025
20 checks passed
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