mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 07:35:18 +00:00
community[patch]: chat message history mypy fixes (#17059)
Related to #17048
This commit is contained in:
parent
af5ae24af2
commit
d93de71d08
@ -47,7 +47,7 @@ class ElasticsearchChatMessageHistory(BaseChatMessageHistory):
|
|||||||
):
|
):
|
||||||
self.index: str = index
|
self.index: str = index
|
||||||
self.session_id: str = session_id
|
self.session_id: str = session_id
|
||||||
self.ensure_ascii: bool = esnsure_ascii # type: ignore[assignment]
|
self.ensure_ascii = esnsure_ascii
|
||||||
|
|
||||||
# Initialize Elasticsearch client from passed client arg or connection info
|
# Initialize Elasticsearch client from passed client arg or connection info
|
||||||
if es_connection is not None:
|
if es_connection is not None:
|
||||||
@ -177,7 +177,7 @@ class ElasticsearchChatMessageHistory(BaseChatMessageHistory):
|
|||||||
"created_at": round(time() * 1000),
|
"created_at": round(time() * 1000),
|
||||||
"history": json.dumps(
|
"history": json.dumps(
|
||||||
message_to_dict(message),
|
message_to_dict(message),
|
||||||
ensure_ascii=self.ensure_ascii,
|
ensure_ascii=bool(self.ensure_ascii),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
refresh=True,
|
refresh=True,
|
||||||
|
@ -39,7 +39,7 @@ class BaseMessageConverter(ABC):
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
def create_message_model(table_name, DynamicBase): # type: ignore
|
def create_message_model(table_name: str, DynamicBase: Any) -> Any:
|
||||||
"""
|
"""
|
||||||
Create a message model for a given table name.
|
Create a message model for a given table name.
|
||||||
|
|
||||||
@ -52,8 +52,8 @@ def create_message_model(table_name, DynamicBase): # type: ignore
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Model decleared inside a function to have a dynamic table name
|
# Model declared inside a function to have a dynamic table name.
|
||||||
class Message(DynamicBase):
|
class Message(DynamicBase): # type: ignore[valid-type, misc]
|
||||||
__tablename__ = table_name
|
__tablename__ = table_name
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
session_id = Column(Text)
|
session_id = Column(Text)
|
||||||
|
@ -40,7 +40,7 @@ class TiDBChatMessageHistory(BaseChatMessageHistory):
|
|||||||
self.session_id = session_id
|
self.session_id = session_id
|
||||||
self.table_name = table_name
|
self.table_name = table_name
|
||||||
self.earliest_time = earliest_time
|
self.earliest_time = earliest_time
|
||||||
self.cache = [] # type: ignore[var-annotated]
|
self.cache: List = []
|
||||||
|
|
||||||
# Set up SQLAlchemy engine and session
|
# Set up SQLAlchemy engine and session
|
||||||
self.engine = create_engine(connection_string)
|
self.engine = create_engine(connection_string)
|
||||||
|
Loading…
Reference in New Issue
Block a user