Skip to content

Commit d00f9e6

Browse files
[FIX] Added missing stream_update() Method (#1675)
* Added missing stream result method * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 24d2123 commit d00f9e6

File tree

1 file changed

+22
-0
lines changed
  • unstract/sdk1/src/unstract/sdk1/tool

1 file changed

+22
-0
lines changed

unstract/sdk1/src/unstract/sdk1/tool/stream.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
from typing import Any
66

7+
from deprecated import deprecated
78
from unstract.sdk1.constants import Command, LogLevel, LogStage, ToolEnv
89
from unstract.sdk1.exceptions import SdkError
910
from unstract.sdk1.utils.common import Utils
@@ -234,3 +235,24 @@ def stream_update(message: str, state: str, **kwargs: dict[str, Any]) -> None:
234235
**kwargs,
235236
}
236237
print(json.dumps(record))
238+
239+
@staticmethod
240+
@deprecated(version="0.4.4", reason="Use `BaseTool.write_to_result()` instead")
241+
def stream_result(result: dict[Any, Any], **kwargs: dict[str, Any]) -> None:
242+
"""Streams tool result (review if required).
243+
244+
Args:
245+
result (dict): The result of the tool. Refer to the
246+
Unstract protocol for the format of the result.
247+
**kwargs: Additional keyword arguments to include in the record.
248+
249+
Returns:
250+
None
251+
"""
252+
record = {
253+
"type": "RESULT",
254+
"result": result,
255+
"emitted_at": datetime.datetime.now().isoformat(),
256+
**kwargs,
257+
}
258+
print(json.dumps(record))

0 commit comments

Comments
 (0)