Skip to content
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

(bug-fix) Fix not adding first node in empty graph DB #1958

Closed
wants to merge 1 commit into from

Conversation

elifiner
Copy link

Description

This fixes graph nodes not being created at all for an empty graph.

Done some debugging and found that in graph_memory.py:102 the LLM chooses the NOOP tool despite a clear indication that a memory should be added:

Further digging and #1879 (comment) showed that the LLM doesn't understand correctly [] as a lack of existing nodes.

The change replaces [] with the word "None" which seems to work.

Fixes #1906

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Used the sample graph code from the docs (https://docs.mem0.ai/open-source/graph_memory/overview) with an empty Neo4J DB at Aura:

import os
from dotenv import load_dotenv
load_dotenv()
from mem0 import Memory

config = {
    "graph_store": {
        "provider": "neo4j",
        "config": {
            "url": os.environ["NEO4J_URL"],
            "username": os.environ["NEO4J_USERNAME"],
            "password": os.environ["NEO4J_PASSWORD"]
        }
    },
    "version": "v1.1"
}

m = Memory.from_config(config)
m.add("I like pizza", user_id="alice2")
results = m.search("What food do I like?", user_id="alice2")
print(results)
  • Test Script (please provide)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and Existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

@CLAassistant
Copy link

CLAassistant commented Oct 15, 2024

CLA assistant check
All committers have signed the CLA.

@elifiner
Copy link
Author

Unfortunately this fix works only sporadically. A more permanent fix is to remove the NOOP tool, but that also means unnecessary updates get sent to the graph DB. Hope you guys figure out a proper fix for this.

Closing the PR.

@elifiner elifiner closed this Oct 15, 2024
@deshraj
Copy link
Collaborator

deshraj commented Oct 15, 2024

Thanks for pointing this out. @prateekchhikara can we please check this issue and fix it properly?

@koi646
Copy link
Contributor

koi646 commented Oct 21, 2024

This persistent problem makes neo4j directly unusable

@prateekchhikara
Copy link
Collaborator

@koi646 we are looking into this issue and will soon release a patch.

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.

Graph memory example throws error with Neo4j
5 participants