Skip to content

Commit

Permalink
[CLI] Add auth env var
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Dec 14, 2024
1 parent 9291ae8 commit dbf5b49
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 118 deletions.
16 changes: 16 additions & 0 deletions libs/cli/langgraph_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class StoreConfig(TypedDict, total=False):
"""Configuration for vector embeddings in store."""


class AuthConfig(TypedDict, total=False):
path: str
disable_studio_auth: bool


class Config(TypedDict, total=False):
python_version: str
node_version: Optional[str]
Expand All @@ -56,6 +61,7 @@ class Config(TypedDict, total=False):
graphs: dict[str, str]
env: Union[dict[str, str], str]
store: Optional[StoreConfig]
auth: Optional[dict[str, str]]


def _parse_version(version_str: str) -> tuple[int, int]:
Expand Down Expand Up @@ -88,6 +94,7 @@ def validate_config(config: Config) -> Config:
"graphs": config.get("graphs", {}),
"env": config.get("env", {}),
"store": config.get("store"),
"auth": config.get("auth"),
}
if config.get("node_version")
else {
Expand All @@ -98,6 +105,7 @@ def validate_config(config: Config) -> Config:
"graphs": config.get("graphs", {}),
"env": config.get("env", {}),
"store": config.get("store"),
"auth": config.get("auth"),
}
)

Expand Down Expand Up @@ -400,6 +408,10 @@ def python_config_to_docker(config_path: pathlib.Path, config: Config, base_imag
ENV LANGGRAPH_STORE='{json.dumps(store_config)}'
"""
)
if (auth_config := config.get("auth")) is not None:
env_additional_config += f"""
ENV LANGGRAPH_AUTH='{json.dumps(auth_config)}'
"""
return f"""FROM {base_image}:{config['python_version']}
{os.linesep.join(config["dockerfile_lines"])}
Expand Down Expand Up @@ -445,6 +457,10 @@ def test_file(file_name):
ENV LANGGRAPH_STORE='{json.dumps(store_config)}'
"""
)
if (auth_config := config.get("auth")) is not None:
env_additional_config += f"""
ENV LANGGRAPH_AUTH='{json.dumps(auth_config)}'
"""
return f"""FROM {base_image}:{config['node_version']}
{os.linesep.join(config["dockerfile_lines"])}
Expand Down
Loading

0 comments on commit dbf5b49

Please sign in to comment.