Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Pass ENV from backend to tool #1064

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class ToolRuntimeVariable:
EXECUTION_BY_TOOL = "EXECUTION_BY_TOOL"
WORKFLOW_EXECUTION_DIR_PREFIX = "WORKFLOW_EXECUTION_DIR_PREFIX"
API_EXECUTION_DIR_PREFIX = "API_EXECUTION_DIR_PREFIX"
REDIS_HOST = "REDIS_HOST"
REDIS_PORT = "REDIS_PORT"
REDIS_USER = "REDIS_USER"
REDIS_PASSWORD = "REDIS_PASSWORD"


class WorkflowFileType:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def __init__(
self.llmw_max_polls = ToolsUtils.get_env(
ToolRV.ADAPTER_LLMW_MAX_POLLS, raise_exception=False
)
self.redis_host = ToolsUtils.get_env(ToolRV.REDIS_HOST, raise_exception=True)
self.redis_port = ToolsUtils.get_env(ToolRV.REDIS_PORT, raise_exception=True)
self.redis_user = ToolsUtils.get_env(ToolRV.REDIS_USER, raise_exception=True)
self.redis_password = ToolsUtils.get_env(
ToolRV.REDIS_PASSWORD, raise_exception=True
)

def set_messaging_channel(self, messaging_channel: str) -> None:
self.messaging_channel = messaging_channel
Expand Down Expand Up @@ -219,6 +225,10 @@ def get_tool_environment_variables(self) -> dict[str, Any]:
ToolRV.X2TEXT_HOST: self.x2text_host,
ToolRV.X2TEXT_PORT: self.x2text_port,
ToolRV.EXECUTION_BY_TOOL: True,
ToolRV.REDIS_HOST: self.redis_host,
ToolRV.REDIS_PORT: self.redis_port,
ToolRV.REDIS_USER: self.redis_user,
ToolRV.REDIS_PASSWORD: self.redis_password,
}
# For async LLM Whisperer extraction
if self.llmw_poll_interval:
Expand All @@ -243,6 +253,6 @@ def get_env(env_key: str, raise_exception: bool = False) -> Optional[str]:
Optional[str]: Value for the env variable
"""
env_value = os.environ.get(env_key)
if (env_value is None or env_value == "") and raise_exception:
if (env_value is None) and raise_exception:
raise MissingEnvVariable(f"Env variable {env_key} is required")
return env_value
Loading