🚀 feat(memories.py): add default value for connection_string field in PostgresChatMessageHistoryFrontendNode

The trailing whitespace has been removed for consistency and readability. The unused import of `DEFAULT_CONNECTION_STRING` from `langchain.memory.chat_message_histories.postgres` has been removed. The `PostgresChatMessageHistoryFrontendNode` now has a default value for the `connection_string` field, which is set to `DEFAULT_CONNECTION_STRING`. This ensures that the field has a default value when creating instances of the class.
🔧 chore(memories.py): remove trailing whitespace and unused import
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-29 08:52:45 -03:00
commit 3845a60bcf

View file

@ -3,6 +3,7 @@ from typing import Optional
from langflow.template.field.base import TemplateField
from langflow.template.frontend_node.base import FrontendNode
from langflow.template.template.base import Template
from langchain.memory.chat_message_histories.postgres import DEFAULT_CONNECTION_STRING
class MemoryFrontendNode(FrontendNode):
@ -10,7 +11,7 @@ class MemoryFrontendNode(FrontendNode):
def add_extra_fields(self) -> None:
# chat history should have another way to add common field?
# prevent adding incorect field in ChatMessageHistory
if "BaseChatMessageHistory" in self.base_classes:
if "BaseChatMessageHistory" in self.base_classes:
return
# add return_messages field
@ -95,6 +96,7 @@ class PostgresChatMessageHistoryFrontendNode(MemoryFrontendNode):
required=True,
show=True,
name="connection_string",
value=DEFAULT_CONNECTION_STRING,
),
TemplateField(
field_type="str",
@ -109,7 +111,4 @@ class PostgresChatMessageHistoryFrontendNode(MemoryFrontendNode):
],
)
description: str = "Memory store with Postgres"
base_classes: list[str] = [
"PostgresChatMessageHistory",
"BaseChatMessageHistory"
]
base_classes: list[str] = ["PostgresChatMessageHistory", "BaseChatMessageHistory"]