Skip to content

Enhancement: Add datetime() property to Neo4jMessageHistory #321

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

Open
graphadvantage opened this issue Apr 3, 2025 · 0 comments
Open

Enhancement: Add datetime() property to Neo4jMessageHistory #321

graphadvantage opened this issue Apr 3, 2025 · 0 comments

Comments

@graphadvantage
Copy link

graphadvantage commented Apr 3, 2025

There are no timestamps being written to the Neo4jMessageHistory (neo4j_graphrag.message_history) so it's not really that useful for message analysis, for example it's not easy to query/order recent messages.

https://neo4j.com/docs/neo4j-graphrag-python/current/_modules/neo4j_graphrag/message_history.html#Neo4jMessageHistory

Currently:

ADD_MESSAGE_QUERY = ( "MATCH (s:{node_label}) WHERE s.id = $session_id " "OPTIONAL MATCH (s)-[lm:LAST_MESSAGE]->(last_message) " "CREATE (s)-[:LAST_MESSAGE]->(new:Message) " "SET new += {{role:$role, content:$content}} " "WITH new, lm, last_message WHERE last_message IS NOT NULL " "CREATE (last_message)-[:NEXT]->(new) " "DELETE lm" )

Enhanced:

ADD_MESSAGE_QUERY = ( "MATCH (s:{node_label}) WHERE s.id = $session_id " "OPTIONAL MATCH (s)-[lm:LAST_MESSAGE]->(last_message) " "CREATE (s)-[:LAST_MESSAGE]->(new:Message) " "SET new += {{role:$role, content:$content, datetime: datetime()}} " "WITH new, lm, last_message WHERE last_message IS NOT NULL " "CREATE (last_message)-[:NEXT]->(new) " "DELETE lm" )

Thanks!
Michael

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

No branches or pull requests

1 participant