Files
dify-plugin-sdks/python/examples/code_based_workflow/tools/summary.py
T
2024-12-02 21:10:36 +08:00

21 lines
524 B
Python

from collections.abc import Generator
from dify_plugin.entities.tool import ToolInvokeMessage
from dify_plugin.interfaces.tool import Tool
class Summary(Tool):
def _invoke(
self, tool_parameters: dict
) -> Generator[ToolInvokeMessage, None, None]:
response = self.session.model.summary.invoke(
text="Hello, world!",
instruction="Summarize the text",
)
yield self.create_json_message(
{
"data": response,
}
)