Skip to content

Summarize file

SummarizeFile

Bases: Toolkit

Source code in src/goose/toolkit/summarization/summarize_file.py
class SummarizeFile(Toolkit):
    @tool
    def summarize_file(self, filepath: str, prompt: Optional[str] = None) -> str:
        """
        Tool to summarize a specific file

        Args:
            filepath (str): Path to the file to summarize
            prompt (str): Optional prompt giving the model instructions on how to summarize the file.
                Under the hood this defaults to "Please summarize this file"

        Returns:
            summary (Optional[str]): Summary of the file contents

        """

        exchange = self.exchange_view.accelerator

        _, summary = summarize_file(filepath=filepath, exchange=exchange, prompt=prompt)

        return summary

summarize_file(filepath, prompt=None)

Tool to summarize a specific file

Parameters:

Name Type Description Default
filepath str

Path to the file to summarize

required
prompt str

Optional prompt giving the model instructions on how to summarize the file.
Under the hood this defaults to "Please summarize this file"

None

Returns:

Name Type Description
summary Optional[str]

Summary of the file contents

Source code in src/goose/toolkit/summarization/summarize_file.py
@tool
def summarize_file(self, filepath: str, prompt: Optional[str] = None) -> str:
    """
    Tool to summarize a specific file

    Args:
        filepath (str): Path to the file to summarize
        prompt (str): Optional prompt giving the model instructions on how to summarize the file.
            Under the hood this defaults to "Please summarize this file"

    Returns:
        summary (Optional[str]): Summary of the file contents

    """

    exchange = self.exchange_view.accelerator

    _, summary = summarize_file(filepath=filepath, exchange=exchange, prompt=prompt)

    return summary