-
Notifications
You must be signed in to change notification settings - Fork 85
feat: Adding PGChatMessageHistory #203
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
base: main
Are you sure you want to change the base?
Conversation
feat: Add PGChatMessageHistory
chore(docs): Add documentation for PGChatMessageHistory
else: | ||
return f"""SELECT data, type FROM "{self.schema_name}"."{self.table_name}" WHERE session_id = :session_id ORDER BY id;""" | ||
|
||
def _convert_to_messages(self, rows: Sequence[RowMapping]) -> list[BaseMessage]: |
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.
nit: make private
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.
I've left some functions to be semi private so we can override them in the google integrations. These are mostly related to how the data is to be pulled from the db or added in depending on the schema
session_id: str, | ||
table_name: str, | ||
store_message: bool, | ||
schema_name: str = "public", |
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.
Linting:
- Use a boolean trap (h)ttps://docs.astral.sh/ruff/rules/boolean-type-hint-positional-argument/
- schema_name takes a default, so put it after a
*
operator
self, | ||
key: object, | ||
pool: AsyncEngine, | ||
session_id: str, |
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.
Could you sanitize the table name and schema name? It looks like it's possible to inject SQL
await conn.execute(text(create_table_query)) | ||
await conn.commit() | ||
|
||
async def ainit_chat_history_table( |
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.
The engine abstraction is coupling vectorstores and chat history which are two completely different things.
Missing a compositional pattern and an admin layer for chat history + vectorstors to be able to create / drop tables
Looks pretty good overall! A few comments:
|
feat: Adding PGChatMessageHistory along with it's documentation
Not deprecating the PostgresChatMessageHistory for now (as the deprcation for PGVector has been removed).