From 3bee0294f652b483a8ef75e013712ba48e4cb90a Mon Sep 17 00:00:00 2001 From: pk-zipstack Date: Fri, 21 Nov 2025 19:23:15 +0530 Subject: [PATCH 1/2] Added missing stream result method --- .../sdk1/src/unstract/sdk1/tool/stream.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/unstract/sdk1/src/unstract/sdk1/tool/stream.py b/unstract/sdk1/src/unstract/sdk1/tool/stream.py index 0fde90efa8..18a93fee57 100644 --- a/unstract/sdk1/src/unstract/sdk1/tool/stream.py +++ b/unstract/sdk1/src/unstract/sdk1/tool/stream.py @@ -3,6 +3,7 @@ import logging import os from typing import Any +from deprecated import deprecated from unstract.sdk1.constants import Command, LogLevel, LogStage, ToolEnv from unstract.sdk1.exceptions import SdkError @@ -234,3 +235,24 @@ def stream_update(message: str, state: str, **kwargs: dict[str, Any]) -> None: **kwargs, } print(json.dumps(record)) + + @staticmethod + @deprecated(version="0.4.4", reason="Use `BaseTool.write_to_result()` instead") + def stream_result(result: dict[Any, Any], **kwargs: dict[str, Any]) -> None: + """Streams tool result (review if required). + + Args: + result (dict): The result of the tool. Refer to the + Unstract protocol for the format of the result. + **kwargs: Additional keyword arguments to include in the record. + + Returns: + None + """ + record = { + "type": "RESULT", + "result": result, + "emitted_at": datetime.datetime.now().isoformat(), + **kwargs, + } + print(json.dumps(record)) \ No newline at end of file From 60f09729bf409451b5e3bc3e8ce7811f1ec7c922 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 13:58:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unstract/sdk1/src/unstract/sdk1/tool/stream.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unstract/sdk1/src/unstract/sdk1/tool/stream.py b/unstract/sdk1/src/unstract/sdk1/tool/stream.py index 18a93fee57..92e3b67356 100644 --- a/unstract/sdk1/src/unstract/sdk1/tool/stream.py +++ b/unstract/sdk1/src/unstract/sdk1/tool/stream.py @@ -3,8 +3,8 @@ import logging import os from typing import Any -from deprecated import deprecated +from deprecated import deprecated from unstract.sdk1.constants import Command, LogLevel, LogStage, ToolEnv from unstract.sdk1.exceptions import SdkError from unstract.sdk1.utils.common import Utils @@ -255,4 +255,4 @@ def stream_result(result: dict[Any, Any], **kwargs: dict[str, Any]) -> None: "emitted_at": datetime.datetime.now().isoformat(), **kwargs, } - print(json.dumps(record)) \ No newline at end of file + print(json.dumps(record))