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]: agentchat_graph_rag_neo4j/ Notebook: queryengine.query always returns empty #306

Open
tyler-suard-parker opened this issue Dec 27, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@tyler-suard-parker
Copy link

tyler-suard-parker commented Dec 27, 2024

Describe the bug

@Eric-Shang Sorry to bother you again, I know you must be very busy. I got the LLM and the embedding up and running, but the Neo4jGraphQueryEngine is returning empty every time.

I used neo4j.GraphDatabase to test my database connection, and it works, I can query the database. However, when I try to use the Neo4jGraphQueryEngine to query the same database with the same credentials, it always returns empty.

from neo4j import GraphDatabase

URI = "neo4j://computer-url"
AUTH = ("username", "password")

with GraphDatabase.driver(URI, auth=AUTH) as driver:
    driver.verify_connectivity()
    print("Connection established.")

    records, summary, keys = driver.execute_query(
        "MATCH (n) RETURN n LIMIT 5",
        database_="",
    )

    for record in records:
        print(record.data()) 
driver.close()

Output:
{'n': {'Status': 'ACTIVE', 'LogStatus': 'First Snapshot', 'UCMType': '1-DISTRIBUTOR','}}
{'n': {'Status': 'ACTIVE', 'LogStatus': 'First Snapshot', 'UCMType': '1-DISTRIBUTOR',}}
{'n': {'Status': 'ACTIVE', 'LogStatus': 'First Snapshot', 'UCMType': '8-DIRECT CUSTOMER',}}
{'n': {'Status': 'ACTIVE', 'Addr1': 'UNKNOWN-001144', 'LastUpdate': '2023-07-11 09:40:03.203'}}
{'n': {'Status': 'ACTIVE', 'Addr1': '747 ZECKENDORF BLVD', 'LastUpdate': '2023-07-11 09:40:03.}}

query_engine = Neo4jGraphQueryEngine(
username="username",
password="password",
port=1234,
host="neo4j://computer-url",
database="database",
llm=llm,
embedding=embed_model,
)
query_engine.connect_db()

results = query_engine.query("Return all records", n_results=5) #I also tried this with MATCH (n) RETURN n LIMIT 5
print(results)

Output:
GraphStoreQueryResult(answer='Empty Response', results=[])

Steps to reproduce

Run this notebook:
https://github.com/ag2ai/ag2/blob/main/notebook/agentchat_graph_rag_neo4j.ipynb

After creating the query engine, run this code:

query_engine.connect_db()

results = query_engine.query("Return all records", n_results=5)
print(results)

Model Used

gpt-4

Expected Behavior

It should have returned any 5 records.

Screenshots and logs

Additional Information

No response

@tyler-suard-parker tyler-suard-parker added the bug Something isn't working label Dec 27, 2024
@Eric-Shang
Copy link
Collaborator

Eric-Shang commented Dec 30, 2024

Unfortunately, now the query engine can only answer questions based on the context in the database but can't create cypher query from natural language with input like your example, which I don't think is part of graph rag's capability.

I'm curious about your use case. Do you want to use query engine directly to help execute database operations with human language?

@tyler-suard-parker
Copy link
Author

@Eric-Shang I found that when I run .initiate_chat() in the notebook, it always returns an empty result. I drilled down a little deeper and found that .initiate_chat() calls query_engine.query(), which always returns 'Empty Response', so I think that may be why the agents always return an empty result.

@Tylersuard
Copy link

@Eric-Shang Just to be clear, every time I run the notebook using Azure OpenAI for my LLM, the .initiate_chat() method causes my agents to converse, but one agent always returns "Empty Response". I am not sure how to fix this.

@Eric-Shang
Copy link
Collaborator

Eric-Shang commented Jan 5, 2025

@tyler-suard-parker Sorry for late reply. Are you using our given notebook or the above one? As I mentioned, query engine won't be able to answer "Return all records" because the question has no context (it doesn't know what "records" refer to). If you ask specific questions about an entity or relationship, it should be able to answer. Could you share me with other questions that you got empty response and the expected answers?

Btw, Sometimes I may miss email notification. You could ping me on Discord. I sent you a DM on Discord before (My discord name is JS).

@Eric-Shang
Copy link
Collaborator

If you always gets empty response, it might be easier for us to talk about more details on Discord, and probably we can debug together, since I can't reproduce the error on my end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants