Home / Function/ predict_new_summary() — langchain Function Reference

predict_new_summary() — langchain Function Reference

Architecture documentation for the predict_new_summary() function in summary.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  440abe33_20df_ee02_d771_d5bb5d39241f["predict_new_summary()"]
  b59972c7_2658_48b0_f600_7b1f592481af["SummarizerMixin"]
  440abe33_20df_ee02_d771_d5bb5d39241f -->|defined in| b59972c7_2658_48b0_f600_7b1f592481af
  1f012672_a4f9_fcdb_ebce_4907d85c70cf["from_messages()"]
  1f012672_a4f9_fcdb_ebce_4907d85c70cf -->|calls| 440abe33_20df_ee02_d771_d5bb5d39241f
  a3263faf_0e13_7f5d_2353_c3f26cefc183["save_context()"]
  a3263faf_0e13_7f5d_2353_c3f26cefc183 -->|calls| 440abe33_20df_ee02_d771_d5bb5d39241f
  style 440abe33_20df_ee02_d771_d5bb5d39241f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/memory/summary.py lines 36–57

    def predict_new_summary(
        self,
        messages: list[BaseMessage],
        existing_summary: str,
    ) -> str:
        """Predict a new summary based on the messages and existing summary.

        Args:
            messages: List of messages to summarize.
            existing_summary: Existing summary to build upon.

        Returns:
            A new summary string.
        """
        new_lines = get_buffer_string(
            messages,
            human_prefix=self.human_prefix,
            ai_prefix=self.ai_prefix,
        )

        chain = LLMChain(llm=self.llm, prompt=self.prompt)
        return chain.predict(summary=existing_summary, new_lines=new_lines)

Domain

Subdomains

Frequently Asked Questions

What does predict_new_summary() do?
predict_new_summary() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/memory/summary.py.
Where is predict_new_summary() defined?
predict_new_summary() is defined in libs/langchain/langchain_classic/memory/summary.py at line 36.
What calls predict_new_summary()?
predict_new_summary() is called by 2 function(s): from_messages, save_context.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free