SummarizerMixin#
- class langchain.memory.summary.SummarizerMixin[source]#
Bases:
BaseModel
Deprecated since version 0.2.12: Refer here for how to incorporate summaries of conversation history: https://langchain-ai.github.io/langgraph/how-tos/memory/add-summary-conversation-history/
Mixin for summarizer.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- param ai_prefix: str = 'AI'#
- param human_prefix: str = 'Human'#
- param llm: BaseLanguageModel [Required]#
- param prompt: BasePromptTemplate = PromptTemplate(input_variables=['new_lines', 'summary'], input_types={}, partial_variables={}, template='Progressively summarize the lines of conversation provided, adding onto the previous summary returning a new summary.\n\nEXAMPLE\nCurrent summary:\nThe human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good.\n\nNew lines of conversation:\nHuman: Why do you think artificial intelligence is a force for good?\nAI: Because artificial intelligence will help humans reach their full potential.\n\nNew summary:\nThe human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good because it will help humans reach their full potential.\nEND OF EXAMPLE\n\nCurrent summary:\n{summary}\n\nNew lines of conversation:\n{new_lines}\n\nNew summary:')#
- param summary_message_cls: Type[BaseMessage] = <class 'langchain_core.messages.system.SystemMessage'>#
- async apredict_new_summary(messages: List[BaseMessage], existing_summary: str) str [source]#
- Parameters:
messages (List[BaseMessage])
existing_summary (str)
- Return type:
str
- predict_new_summary(messages: List[BaseMessage], existing_summary: str) str [source]#
- Parameters:
messages (List[BaseMessage])
existing_summary (str)
- Return type:
str