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

community: update Memgraph integration #27017

Merged
merged 21 commits into from
Dec 10, 2024

Conversation

katarinasupe
Copy link
Contributor

@katarinasupe katarinasupe commented Oct 1, 2024

Description:

  • Memgraph no longer relies on Neo4jGraphStore but implements GraphStore, just like other graph databases.
  • Memgraph no longer relies on GraphQAChain, but implements MemgraphQAChain, just like other graph databases.
  • The refresh schema procedure has been updated to try using SHOW SCHEMA INFO. The fallback uses Cypher queries (a combination of schema and Cypher) → LangChain integration no longer relies on MAGE library.
  • The schema structure has been reformatted. Regardless of the procedures used to get schema, schema structure is the same.
  • The add_graph_documents() method has been implemented. It transforms GraphDocument into Cypher queries and creates a graph in Memgraph. It implements the ability to use baseEntityLabel to improve speed (baseEntityLabel has an index on the id property). It also implements the ability to include sources by creating a MENTIONS relationship to the source document.
  • Jupyter Notebook for Memgraph has been updated.
  • Issue: /
  • Dependencies: /
  • Twitter handle: supe_katarina (DX Engineer @ Memgraph)

Closes #25606

Copy link

vercel bot commented Oct 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 29, 2024 1:19pm

@katarinasupe katarinasupe changed the title Memgraph integration community: update Memgraph integration Oct 1, 2024
@katarinasupe katarinasupe marked this pull request as ready for review October 1, 2024 11:52
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. community Related to langchain-community 🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder labels Oct 1, 2024
@katarinasupe
Copy link
Contributor Author

Hi @baskaryan, tagging as noted in PR template. Please let me know what I need to do regarding the test and what's needed to do in order to get this merged.

@katarinasupe
Copy link
Contributor Author

I managed to fix the CI. Now, all is passing.

Tagging @efriis, as the other person from the PR template for the review. Let me know if someone else should be tagged.

@efriis
Copy link
Member

efriis commented Oct 9, 2024

Hey! Here's a link to the review policy: https://python.langchain.com/docs/contributing/review_process/

Status is currently needs support

@katarinasupe
Copy link
Contributor Author

@efriis is there any update? I have more than 5 upvotes so I am wondering what's the next course of action here and if I can help somehow.

@katarinasupe
Copy link
Contributor Author

Thank you, @libraua, for approving this PR. Is there something else I need to do to get this PR merged? I wanted to enable Memgraph developers to utilize Memgraph LangChain integration with the latest improvements.

Copy link
Collaborator

@ccurme ccurme left a comment

Choose a reason for hiding this comment

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

Hi @katarinasupe, I don't want to block this but have some qualms about MemgraphQAChain. I think the fact that other graph databases implement custom Chain classes is not an advantage and may not be desirable to emulate. MemgraphQAChain also uses LLMChain, which is deprecated (I include a comment below).

LangChain is investing in LangGraph, and instead of releasing and maintaining a v0.0 abstraction, you could advantage yourself by implementing these as tools and adding documentation demonstrating their use in question-answering using a modern agent framework.

Our documentation across integrations has not kept up with our current understanding of best practices, so apologies for the confusion. If you want to move forward with MemgraphQAChain we can go ahead (but suggest we remove LLMChain). Wanted to make sure you're aware of current best practices first.


cypher_generation_chain = LLMChain(
llm=cypher_llm or llm, # type: ignore[arg-type]
**use_cypher_llm_kwargs, # type: ignore[arg-type]
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need use_cypher_llm_kwargs or use_qa_llm_kwargs? Ideally we would avoid LLMChain and just use prompt | llm | parser (e.g., as you do above).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review. Let me digest this today and figure out the next best steps 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ccurme, based on your suggestion, I removed LLMChain. Please let me know if I did that correctly. I changed the code, so it's working for the example provided in the Jupyter Notebook. Let me know if I missed smth while updating chains from LLMChain to Runnable types.

Although it's not ideal, I would like this PR to be merged. I see devs using it, and I would like this work not to go to waste. Still, I am interested in following the best practices out there. I need to take a deeper look at the tools you sent me. If I understood correctly, no other graph database currently follows this approach, or?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ccurme any updates here? I would love to get this merged if possible 🙏

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Dec 10, 2024
@ccurme ccurme merged commit aba2711 into langchain-ai:master Dec 10, 2024
21 checks passed
@pthalasta
Copy link

@ccurme is this available as part of langchain-core==0.3.23?

@ccurme
Copy link
Collaborator

ccurme commented Dec 10, 2024

This will be available in the next release of langchain-community (0.3.11)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community 🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder lgtm PR looks good. Use to confirm that a PR is ready for merging. size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Unable to insert GraphDocuments into Memgraph
5 participants