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

feat: add MySQLChatMessageHistory class #10

Merged
merged 6 commits into from
Jan 30, 2024
Merged

feat: add MySQLChatMessageHistory class #10

merged 6 commits into from
Jan 30, 2024

Conversation

jackwotherspoon
Copy link
Contributor

@jackwotherspoon jackwotherspoon commented Jan 26, 2024

Adding MySQLChatMessageHistory class which allows functionality of a memory store.

Follows pattern of other chat message history integrations: https://github.com/langchain-ai/langchain/tree/master/libs/community/langchain_community/chat_message_histories

@jackwotherspoon jackwotherspoon requested review from totoleon, loeng2023 and a team January 26, 2024 15:23
@jackwotherspoon jackwotherspoon self-assigned this Jan 26, 2024
@jackwotherspoon jackwotherspoon removed the request for review from a team January 26, 2024 15:28
Comment on lines +55 to +57
# load SQLAlchemy row objects into dicts
items = [json.loads(result[0]) for result in results]
messages = messages_from_dict(items)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@totoleon I updated this code from the POC to use messages_from_dict instead of message_chunk_to_message.

It now returns the proper HumanMessage and AIMessage message objects as the other current integrations do. Let me know what you think 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you test it? It was messages_from_dict copied from the pg PoC code, but it didn't work for some reason, and got fixed after I changed to message_chunk_to_message.

I didn't dive deep though. It should be fine if you were able to make it work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup the integration test works wonders, the trick was json.loads to turn the string into a dict.

@jackwotherspoon jackwotherspoon requested a review from a team as a code owner January 26, 2024 19:20
@jackwotherspoon jackwotherspoon removed the request for review from a team January 26, 2024 19:21
Base automatically changed from staging to main January 30, 2024 19:43
@jackwotherspoon jackwotherspoon changed the base branch from main to staging January 30, 2024 19:45
@jackwotherspoon jackwotherspoon merged commit 190c20f into staging Jan 30, 2024
8 checks passed
@jackwotherspoon jackwotherspoon deleted the memory branch January 30, 2024 19:53
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.

2 participants