-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(community): Neo4j chat message history #7331
feat(community): Neo4j chat message history #7331
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok overall, will tag in @tomasonjo for a look too though!
Thanks for the feedback, @jacoblee93 ! I'll run |
…sync factory function
…nction; prefer expect-error over ignore
Thanks for the review - your requested changes are in, @jacoblee93 🚀 |
cc: @adam-cowley |
Can you copy some connection validation and query execution from: https://github.com/langchain-ai/langchainjs/blob/main/libs/langchain-community/src/graphs/neo4j_graph.ts#L312 |
Thanks for reviewing @tomasonjo 🙌 To your first ask, I do have a To your second ask, I'd like to make sure I'm understanding you correctly: You'd like the |
No, no need for arbitrary queries. Just change session run to driver
execute query
V pet., 13. dec. 2024, 17:02 je oseba Bernard F Faucher <
***@***.***> napisala:
… Can you copy some connection validation and query execution from:
https://github.com/langchain-ai/langchainjs/blob/main/libs/langchain-community/src/graphs/neo4j_graph.ts#L312
Thanks for reviewing @tomasonjo <https://github.com/tomasonjo> 🙌
To your first ask, I do have a verifyConnection
<https://github.com/langchain-ai/langchainjs/pull/7331/files#diff-ebd6083757dd12c113f92ca3eca68fb12c389133b082cc391f8f3924db3edc59R85-R88>
class method that's public, called as part of the initialize
<https://github.com/langchain-ai/langchainjs/pull/7331/files#diff-ebd6083757dd12c113f92ca3eca68fb12c389133b082cc391f8f3924db3edc59R71-R80>
factory method, and included in the test suite
<https://github.com/langchain-ai/langchainjs/pull/7331/files#diff-8ed0e6b3000d381fba19719b0e57b2e71e98a78a13ee24d9be2f21b1a32a954cR74-R77>.
Did you have something else in mind for connection validation?
To your second ask, I'd like to make sure I'm understanding you correctly:
You'd like the Neo4jChatMessageHistory class to be able to execute
arbitrary Cypher queries on the underlying database? It's totally doable,
it just seems like something better left to the Neo4jGraph class. If the
intention is to avoid two expensive calls to neo4j.driver, an option
might be to take an existing instance of a Neo4jGraph as an optional prop
in the constructor, adjusting some of the surrounding logic accordingly.
I'd considered going that route when first planning the code, but decided
against it because of the APOC dependency. Does that sound preferable, or
is giving Neo4jChatMessageHistory a query method what you're looking for?
—
Reply to this email directly, view it on GitHub
<#7331 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEYGGTOTUEDDVBJXESJBTUD2FMALBAVCNFSM6AAAAABTG66EK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBRG43DKOBTGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I understand - thanks for clarifying! I'll get right on it 💨 |
@tomasonjo Your requested changes are in & all tests are green ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
|
What? Why?
This PR adds the Neo4jChatMessageHistory class to
@langchain/community
, in furtherance of reaching functional parity with the Python version of the package. PTAL 👀Tests?
Yes! A new integration test is added to the corresponding
tests
folder, covering all the new functionality in well-scopeddescribe/it
blocks, including set-up and tear-down. To facilitate testing, the neo4j service has also been added totest-int-deps-docker-compose.yml
, pinned to the latest image. To start the test container, run:docker-compose -f test-int-deps-docker-compose.yml up -d
from the project root, then run the test with:yarn run test:single src/stores/tests/neo4j.int.test.ts
from thelibs/langchain-community
workspace. Alternatively, you can test against a neo4j server running locally with Neo4j Desktop, or in the cloud using https://sandbox.neo4j.com/ - all three options are working.Demo?
Yes! Here's a gif of the test successfully passing:
And here's a png of what a chat message history persisted with
Neo4jChatMessageHistory
looks like in neo4j:Considerations?
Where sensible, the defaults and conventions of the python code are maintained. Any divergences are configurable, and represent a holistic view of the js/node ecosystem and coding conventions. Raw Cypher passed to the neo4j driver via the new class is tightened up and idiomatic, without hurting query functionality, and uses the params object over string interpolation as much as possible as a security consideration.
Appreciation?
Twitter is not the place to be, but I'd love a friendly shout out on Mastodon at @[email protected] or mention on my LinkedIn 🙏