diff --git a/libs/community/langchain_community/chat_message_histories/elasticsearch.py b/libs/community/langchain_community/chat_message_histories/elasticsearch.py index a9e076563e9..bbd621b98d9 100644 --- a/libs/community/langchain_community/chat_message_histories/elasticsearch.py +++ b/libs/community/langchain_community/chat_message_histories/elasticsearch.py @@ -47,7 +47,7 @@ class ElasticsearchChatMessageHistory(BaseChatMessageHistory): ): self.index: str = index 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 if es_connection is not None: @@ -177,7 +177,7 @@ class ElasticsearchChatMessageHistory(BaseChatMessageHistory): "created_at": round(time() * 1000), "history": json.dumps( message_to_dict(message), - ensure_ascii=self.ensure_ascii, + ensure_ascii=bool(self.ensure_ascii), ), }, refresh=True, diff --git a/libs/community/langchain_community/chat_message_histories/sql.py b/libs/community/langchain_community/chat_message_histories/sql.py index fcc3ac71ab1..e30a86a52d6 100644 --- a/libs/community/langchain_community/chat_message_histories/sql.py +++ b/libs/community/langchain_community/chat_message_histories/sql.py @@ -39,7 +39,7 @@ class BaseMessageConverter(ABC): 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. @@ -52,8 +52,8 @@ def create_message_model(table_name, DynamicBase): # type: ignore """ - # Model decleared inside a function to have a dynamic table name - class Message(DynamicBase): + # Model declared inside a function to have a dynamic table name. + class Message(DynamicBase): # type: ignore[valid-type, misc] __tablename__ = table_name id = Column(Integer, primary_key=True) session_id = Column(Text) diff --git a/libs/community/langchain_community/chat_message_histories/tidb.py b/libs/community/langchain_community/chat_message_histories/tidb.py index 973e97820a2..309ab6d7b12 100644 --- a/libs/community/langchain_community/chat_message_histories/tidb.py +++ b/libs/community/langchain_community/chat_message_histories/tidb.py @@ -40,7 +40,7 @@ class TiDBChatMessageHistory(BaseChatMessageHistory): self.session_id = session_id self.table_name = table_name self.earliest_time = earliest_time - self.cache = [] # type: ignore[var-annotated] + self.cache: List = [] # Set up SQLAlchemy engine and session self.engine = create_engine(connection_string)