[Bug fix] Fix typos, static methods and other sanity improvements in the package (#1129)
This commit is contained in:
@@ -113,10 +113,12 @@ class ChatHistory:
|
||||
count = self.cursor.fetchone()[0]
|
||||
return count
|
||||
|
||||
def _serialize_json(self, metadata: Dict[str, Any]):
|
||||
@staticmethod
|
||||
def _serialize_json(metadata: Dict[str, Any]):
|
||||
return json.dumps(metadata)
|
||||
|
||||
def _deserialize_json(self, metadata: str):
|
||||
@staticmethod
|
||||
def _deserialize_json(metadata: str):
|
||||
return json.loads(metadata)
|
||||
|
||||
def close_connection(self):
|
||||
|
||||
@@ -54,7 +54,7 @@ class ChatMessage(JSONSerializable):
|
||||
if self.human_message:
|
||||
logging.info(
|
||||
"Human message already exists in the chat message,\
|
||||
overwritting it with new message."
|
||||
overwriting it with new message."
|
||||
)
|
||||
|
||||
self.human_message = BaseMessage(content=message, created_by="human", metadata=metadata)
|
||||
@@ -63,7 +63,7 @@ class ChatMessage(JSONSerializable):
|
||||
if self.ai_message:
|
||||
logging.info(
|
||||
"AI message already exists in the chat message,\
|
||||
overwritting it with new message."
|
||||
overwriting it with new message."
|
||||
)
|
||||
|
||||
self.ai_message = BaseMessage(content=message, created_by="ai", metadata=metadata)
|
||||
|
||||
@@ -7,7 +7,7 @@ def merge_metadata_dict(left: Optional[Dict[str, Any]], right: Optional[Dict[str
|
||||
|
||||
Args:
|
||||
left (Dict[str, Any]): metadata of human message
|
||||
right (Dict[str, Any]): metadata of ai message
|
||||
right (Dict[str, Any]): metadata of AI message
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: combined metadata dict with dedup
|
||||
|
||||
Reference in New Issue
Block a user