From 42da6ea16f27c49d7ec029417186e0ffeec14f9b Mon Sep 17 00:00:00 2001 From: langchain-infra <144731603+langchain-infra@users.noreply.github.com> Date: Thu, 19 Oct 2023 13:51:06 -0400 Subject: [PATCH] Infra/add license cli (#254) --- python/langsmith/cli/docker-compose.beta.yaml | 1 + python/langsmith/cli/docker-compose.dev.yaml | 1 + python/langsmith/cli/docker-compose.yaml | 3 +++ python/langsmith/cli/main.py | 16 ++++++++++++++++ python/pyproject.toml | 2 +- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/python/langsmith/cli/docker-compose.beta.yaml b/python/langsmith/cli/docker-compose.beta.yaml index 3b4796ce3..8d5ecc31f 100644 --- a/python/langsmith/cli/docker-compose.beta.yaml +++ b/python/langsmith/cli/docker-compose.beta.yaml @@ -7,6 +7,7 @@ services: - PORT=1985 - LANGCHAIN_ENV=local_docker - LOG_LEVEL=warning + - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY} ports: - 1985:1985 depends_on: diff --git a/python/langsmith/cli/docker-compose.dev.yaml b/python/langsmith/cli/docker-compose.dev.yaml index f2e9f2a1b..6e480093f 100644 --- a/python/langsmith/cli/docker-compose.dev.yaml +++ b/python/langsmith/cli/docker-compose.dev.yaml @@ -7,6 +7,7 @@ services: - PORT=1985 - LANGCHAIN_ENV=local_docker - LOG_LEVEL=warning + - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY} ports: - 1985:1985 depends_on: diff --git a/python/langsmith/cli/docker-compose.yaml b/python/langsmith/cli/docker-compose.yaml index b5824a798..7bd152d44 100644 --- a/python/langsmith/cli/docker-compose.yaml +++ b/python/langsmith/cli/docker-compose.yaml @@ -16,6 +16,7 @@ services: - LANGCHAIN_ENV=local_docker - LOG_LEVEL=warning - OPENAI_API_KEY=${OPENAI_API_KEY} + - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY} ports: - 1984:1984 depends_on: @@ -26,6 +27,7 @@ services: environment: - LANGCHAIN_ENV=local_docker - LOG_LEVEL=warning + - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY} entrypoint: "rq worker --with-scheduler -u redis://langchain-redis:6379 --serializer lc_database.queue.serializer.ORJSONSerializer --worker-class lc_database.queue.worker.Worker --connection-class lc_database.queue.connection.RedisRetry --job-class lc_database.queue.job.AsyncJob" langchain-hub: image: langchain/${_LANGSMITH_IMAGE_PREFIX-}langchainhub-backend:latest @@ -33,6 +35,7 @@ services: - PORT=1985 - LANGCHAIN_ENV=local_docker - LOG_LEVEL=warning + - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY} ports: - 1985:1985 depends_on: diff --git a/python/langsmith/cli/main.py b/python/langsmith/cli/main.py index a1b68fc83..1335e588d 100644 --- a/python/langsmith/cli/main.py +++ b/python/langsmith/cli/main.py @@ -262,6 +262,7 @@ def start( auth_token: Optional[str] = None, stage: Union[Literal["prod"], Literal["dev"], Literal["beta"]] = "prod", openai_api_key: Optional[str] = None, + langsmith_license_key: str, ) -> None: """Run the LangSmith server locally. @@ -275,6 +276,10 @@ def start( If not provided, the OpenAI API Key will be read from the OPENAI_API_KEY environment variable. If neither are provided, some features of LangSmith will not be available. + langsmith_license_key: The LangSmith license key to use for LangSmith + If not provided, the LangSmith license key will be read from the + LANGSMITH_LICENSE_KEY environment variable. If neither are provided, + Langsmith will not start up. """ if stage == "dev": os.environ["_LANGSMITH_IMAGE_PREFIX"] = "dev-" @@ -282,6 +287,8 @@ def start( os.environ["_LANGSMITH_IMAGE_PREFIX"] = "rc-" if openai_api_key is not None: os.environ["OPENAI_API_KEY"] = openai_api_key + if langsmith_license_key is not None: + os.environ["LANGSMITH_LICENSE_KEY"] = langsmith_license_key self.pull(stage=stage) if expose: self._start_and_expose(auth_token=auth_token, stage=stage) @@ -406,12 +413,21 @@ def main() -> None: " OPENAI_API_KEY environment variable. If neither are provided," " some features of LangSmith will not be available.", ) + server_start_parser.add_argument( + "--langsmith-license-key", + default=os.getenv("LANGSMITH_LICENSE_KEY"), + help="The LangSmith license key to use for LangSmith." + " If not provided, the LangSmith License Key will be read from the" + " LANGSMITH_LICENSE_KEY environment variable. If neither are provided," + " the Langsmith application will not spin up.", + ) server_start_parser.set_defaults( func=lambda args: server_command.start( expose=args.expose, auth_token=args.ngrok_authtoken, stage=args.stage, openai_api_key=args.openai_api_key, + langsmith_license_key=args.langsmith_license_key, ) ) diff --git a/python/pyproject.toml b/python/pyproject.toml index 376a265ca..c1049ffce 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langsmith" -version = "0.0.46" +version = "0.0.47" description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform." authors = ["LangChain "] license = "MIT"