community[patch]: chat message history mypy fixes (#17059)

Related to #17048
This commit is contained in:
Bagatur 2024-02-05 13:13:25 -08:00 committed by GitHub
parent af5ae24af2
commit d93de71d08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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)