Skip to content

Commit 9fb46fc

Browse files
passing file execution id from backend to tools (#145)
* passing file execution id from backend to tools * addressed pr comments to set default values
1 parent 12d6529 commit 9fb46fc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/unstract/sdk/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class MetadataKey:
127127
SOURCE_HASH = "source_hash"
128128
WORKFLOW_ID = "workflow_id"
129129
EXECUTION_ID = "execution_id"
130+
FILE_EXECUTION_ID = "file_execution_id"
130131
ORG_ID = "organization_id"
131132
TOOL_META = "tool_metadata"
132133
TOOL_NAME = "tool_name"
@@ -168,3 +169,10 @@ class MimeType:
168169
PDF = "application/pdf"
169170
TEXT = "text/plain"
170171
JSON = "application/json"
172+
173+
174+
class UsageKwargs:
175+
RUN_ID = "run_id"
176+
FILE_NAME = "file_name"
177+
WORKFLOW_ID = "workflow_id"
178+
EXECUTION_ID = "execution_id"

src/unstract/sdk/tool/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def __init__(self, log_level: LogLevel = LogLevel.INFO) -> None:
3939
self.variables = ToolConfigHelper.variables()
4040
self.workflow_id = ""
4141
self.execution_id = ""
42+
self.file_execution_id = ""
43+
self.source_file_name = ""
4244
self.org_id = ""
4345
self._exec_metadata = {}
4446
self.filestorage_provider = None
@@ -84,7 +86,11 @@ def from_tool_args(cls, args: list[str]) -> "BaseTool":
8486
if parsed_args.command not in Command.static_commands():
8587
tool._exec_metadata = tool._get_exec_metadata()
8688
tool.workflow_id = tool._exec_metadata.get(MetadataKey.WORKFLOW_ID)
87-
tool.execution_id = tool._exec_metadata.get(MetadataKey.EXECUTION_ID)
89+
tool.execution_id = tool._exec_metadata.get(MetadataKey.EXECUTION_ID, "")
90+
tool.file_execution_id = tool._exec_metadata.get(
91+
MetadataKey.FILE_EXECUTION_ID, ""
92+
)
93+
tool.source_file_name = tool._exec_metadata.get(MetadataKey.SOURCE_NAME, "")
8894
tool.org_id = tool._exec_metadata.get(MetadataKey.ORG_ID)
8995
return tool
9096

0 commit comments

Comments
 (0)