marvin.fns.summarize

Constants

PROMPT

PROMPT = "'\nYou are an expert summarizer that distills information into clear, concise summaries\nwhile preserving the most important semantic meaning and key points. Examine the \nprovided `data`, text, or information and create a summary that captures the essence\nof the content.\n\nGuidelines for summarization:\n- Maintain objectivity and accuracy\n- Preserve key facts, figures, and relationships\n- Focus on the most important information\n- Use clear, concise language\n- Adapt tone and style to match the content type\n- Ensure the summary stands alone as a coherent piece of text'"

Functions

summarize

def summarize(data: Any, instructions: str | None = None, agent: Agent | None = None, thread: Thread | str | None = None, context: dict[str, Any] | None = None) -> str

Creates a summary of the input data using a language model.

This function uses a language model to analyze the input data and create a concise summary that captures the key information and semantic meaning.

Args: data: The input data to summarize. Can be any type. instructions: Optional additional instructions to guide the summarization. Used to provide specific guidance about what aspects to focus on or how to structure the summary. agent: Optional custom agent to use for summarization. If not provided, the default agent will be used. thread: Optional thread for maintaining conversation context. Can be either a Thread object or a string thread ID. context: Optional dictionary of additional context to include in the task.

Returns: A string containing the generated summary.

Examples:

Basic summarization

summarize(“Long article about climate change…”) ‘Key findings on climate impacts…’

Summarize with specific instructions

summarize(“Technical documentation…”, instructions=“Focus on API changes”) ‘Major API updates include…’

summarize_async

def summarize_async(data: Any, instructions: str | None = None, agent: Agent | None = None, thread: Thread | str | None = None, context: dict[str, Any] | None = None) -> str

Asynchronously creates a summary of the input data using a language model.

This function uses a language model to analyze the input data and create a concise summary that captures the key information and semantic meaning.

Args: data: The input data to summarize. Can be any type. instructions: Optional additional instructions to guide the summarization. Used to provide specific guidance about what aspects to focus on or how to structure the summary. agent: Optional custom agent to use for summarization. If not provided, the default agent will be used. thread: Optional thread for maintaining conversation context. Can be either a Thread object or a string thread ID. context: Optional dictionary of additional context to include in the task.

Returns: A string containing the generated summary.

Examples:

Basic summarization

await summarize_async(“Long article about climate change…”) ‘Key findings on climate impacts…’

Summarize with specific instructions

await summarize_async(“Technical documentation…”, instructions=“Focus on API changes”) ‘Major API updates include…’


Parent Module: fns