Skip to content

Commit 22ebaf3

Browse files
[FIX] Pass ENV from backend to tool (#1064)
Pass ENV from backend to tool Signed-off-by: Deepak <89829542+Deepak-Kesavan@users.noreply.github.com>
1 parent 078bff4 commit 22ebaf3

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

unstract/workflow-execution/src/unstract/workflow_execution/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class ToolRuntimeVariable:
2323
EXECUTION_BY_TOOL = "EXECUTION_BY_TOOL"
2424
WORKFLOW_EXECUTION_DIR_PREFIX = "WORKFLOW_EXECUTION_DIR_PREFIX"
2525
API_EXECUTION_DIR_PREFIX = "API_EXECUTION_DIR_PREFIX"
26+
REDIS_HOST = "REDIS_HOST"
27+
REDIS_PORT = "REDIS_PORT"
28+
REDIS_USER = "REDIS_USER"
29+
REDIS_PASSWORD = "REDIS_PASSWORD"
2630

2731

2832
class WorkflowFileType:

unstract/workflow-execution/src/unstract/workflow_execution/tools_utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def __init__(
5252
self.llmw_max_polls = ToolsUtils.get_env(
5353
ToolRV.ADAPTER_LLMW_MAX_POLLS, raise_exception=False
5454
)
55+
self.redis_host = ToolsUtils.get_env(ToolRV.REDIS_HOST, raise_exception=True)
56+
self.redis_port = ToolsUtils.get_env(ToolRV.REDIS_PORT, raise_exception=True)
57+
self.redis_user = ToolsUtils.get_env(ToolRV.REDIS_USER, raise_exception=True)
58+
self.redis_password = ToolsUtils.get_env(
59+
ToolRV.REDIS_PASSWORD, raise_exception=True
60+
)
5561

5662
def set_messaging_channel(self, messaging_channel: str) -> None:
5763
self.messaging_channel = messaging_channel
@@ -219,6 +225,10 @@ def get_tool_environment_variables(self) -> dict[str, Any]:
219225
ToolRV.X2TEXT_HOST: self.x2text_host,
220226
ToolRV.X2TEXT_PORT: self.x2text_port,
221227
ToolRV.EXECUTION_BY_TOOL: True,
228+
ToolRV.REDIS_HOST: self.redis_host,
229+
ToolRV.REDIS_PORT: self.redis_port,
230+
ToolRV.REDIS_USER: self.redis_user,
231+
ToolRV.REDIS_PASSWORD: self.redis_password,
222232
}
223233
# For async LLM Whisperer extraction
224234
if self.llmw_poll_interval:
@@ -243,6 +253,6 @@ def get_env(env_key: str, raise_exception: bool = False) -> Optional[str]:
243253
Optional[str]: Value for the env variable
244254
"""
245255
env_value = os.environ.get(env_key)
246-
if (env_value is None or env_value == "") and raise_exception:
256+
if (env_value is None) and raise_exception:
247257
raise MissingEnvVariable(f"Env variable {env_key} is required")
248258
return env_value

0 commit comments

Comments
 (0)