memoryscope.core.chat.base_memory_chat
- class memoryscope.core.chat.base_memory_chat.BaseMemoryChat(**kwargs)[源代码]
基类:
object
An abstract base class representing a chat system integrated with memory services. It outlines the method to initiate a chat session leveraging memory data, which concrete subclasses must implement.
- property memory_service: BaseMemoryService
Abstract property to access the memory service.
- 抛出:
NotImplementedError -- This method should be implemented in a subclass.
- abstract chat_with_memory(query: str, role_name: str | None = None, system_prompt: str | None = None, memory_prompt: str | None = None, temporary_memories: str | None = None, history_message_strategy: Literal['auto', None] | int = 'auto', remember_response: bool = True, **kwargs)[源代码]
The core function that carries out conversation with memory accepts user queries through query and returns the conversation results through model_response. The retrieved memories are stored in the memories within meta_data. :param query: User's query, includes the user's question. :type query: str :param role_name: User's role name. :type role_name: str, optional :param system_prompt: System prompt. Defaults to the system_prompt in "memory_chat_prompt.yaml". :type system_prompt: str, optional :param memory_prompt: Memory prompt, It takes effect when there is a memory and will be placed in
front of the retrieved memory. Defaults to the memory_prompt in "memory_chat_prompt.yaml".
- 参数:
temporary_memories (str, optional) -- Manually added user memory in this function.
history_message_strategy ("auto", None, int) --
- If it is set to "auto", the history messages in the conversation will retain those that have not
yet been summarized. Default to "auto".
If it is set to None, no conversation history will be saved.
If it is set to an integer value "n", recent "n" message-pair[user, assistant] will be retained.
remember_response (bool, optional) -- Flag indicating whether to save the AI's response to memory. Defaults to False.
- 返回:
In non-streaming mode, returns a complete AI response. - ModelResponseGen: In streaming mode, returns a generator yielding AI response parts. - Memories: To obtain the memory by invoking the method of model_response.meta_data[MEMORIES]
- 返回类型:
ModelResponse