Skip to content

Text summary task

TextSummaryTask

Bases: BaseTextInputTask

Source code in griptape/tasks/text_summary_task.py
@define
class TextSummaryTask(BaseTextInputTask):
    _summary_engine: Optional[BaseSummaryEngine] = field(default=None, alias="summary_engine")

    @property
    def summary_engine(self) -> Optional[BaseSummaryEngine]:
        if self._summary_engine is None:
            if self.structure is not None:
                self._summary_engine = PromptSummaryEngine(prompt_driver=self.structure.config.prompt_driver)
            else:
                raise ValueError("Summary Engine is not set.")
        return self._summary_engine

    @summary_engine.setter
    def summary_engine(self, value: BaseSummaryEngine) -> None:
        self._summary_engine = value

    def run(self) -> TextArtifact:
        return TextArtifact(self.summary_engine.summarize_text(self.input.to_text(), rulesets=self.all_rulesets))

summary_engine: Optional[BaseSummaryEngine] property writable

run()

Source code in griptape/tasks/text_summary_task.py
def run(self) -> TextArtifact:
    return TextArtifact(self.summary_engine.summarize_text(self.input.to_text(), rulesets=self.all_rulesets))