pangukitsappdev.memory package¶
Submodules¶
pangukitsappdev.memory.conversation_summory_memory module¶
- class pangukitsappdev.memory.conversation_summory_memory.ConversationSummaryBufferMemory(*, chat_memory: BaseChatMessageHistory = None, output_key: Optional[str] = None, input_key: Optional[str] = None, return_messages: bool = False, buffer: str = '', summary_skill: SimpleSkill, human_prefix: str = 'Human', ai_prefix: str = 'AI', memory_key: str = 'history')¶
基类:
BaseChatMemory
Buffer with summarizer for storing conversation memory.
- ai_prefix: str¶
- buffer: str¶
- clear() None ¶
Clear memory contents.
- human_prefix: str¶
- load_memory_variables(inputs: Dict[str, Any]) Dict[str, Any] ¶
Return history buffer.
- memory_key: str¶
- save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) None ¶
Save context from this conversation to buffer.
- summary_skill: SimpleSkill¶
pangukitsappdev.memory.redis_message_history module¶
- class pangukitsappdev.memory.redis_message_history.RedisMessageHistory(msg_history_config: Optional[MessageHistoryConfig] = None)¶
基类:
RedisChatMessageHistory
继承 langchain RedisChatMessageHistory,根据 MessageHistoryConfig传参
pangukitsappdev.memory.sql_message_history module¶
- class pangukitsappdev.memory.sql_message_history.SQLMessageHistory(msg_history_config: Optional[MessageHistoryConfig] = None)¶
基类:
BaseChatMessageHistory
SQLMessageHistory重写
- add_message(message: BaseMessage) None ¶
新增 message 前移除过期 message
- clear() None ¶
删除 session_tag 所有 message
- evict() None ¶
根据 ttl 删除过期 message
- property messages: List[BaseMessage]¶
返回所有 session_tag下 message
- pangukitsappdev.memory.sql_message_history.create_message_model_with_create_date(table_name, dynamic_base)¶
基于表名创建 message model 对比 langchain SQLChatMessageHistory新增 create_date Args:
table_name: The name of the table to use. dynamic_base: The base class to use for the model.
- Returns:
The model class.
- pangukitsappdev.memory.sql_message_history.message_to_dict(message: BaseMessage) dict ¶