docs: Rename deploy directory to cloud (#732)

* Rename deploy to cloud.

* Fix link for streaming pages.
This commit is contained in:
Andrew Nguonly
2024-06-20 14:44:51 -07:00
committed by GitHub
parent 3e1e3fbac9
commit e4de6bc49a
18 changed files with 29 additions and 29 deletions
+24
View File
@@ -0,0 +1,24 @@
# API Concepts
This page discusses high-level concepts of the LangGraph Cloud.
## Assistant
An assistant is a configured instance of a [`CompiledGraph`](../reference/graphs/#compiledgraph). It abstracts the cognitive architecture of the graph and contains instance specific configuration and metadata. Multiple assistants can reference the same graph but can contain different configuration and metadata, which may differentiate the behavior of the assistants.
An assistant (i.e. the graph) is invoked as part of a [run](#run).
## Thread
A thread contains the accumulated state of a group of [runs](#run). If a run is executed on a thread, then the [state](../concepts/#state-management) of the underlying graph of the [assistant](#assistant) will be persisted to the thread. A thread's current and historical state can be retrieved.
To persist state, a thread must be created prior to executing a run.
## Run
A run is an invocation of an [assistant](#assistant). Each run may have its own input, configuration, and metadata, which may affect execution and output of the underlying graph. A run can optionally be executed on a [thread](#thread).
## Streaming
Streaming is critical in making applications based on LLMs feel responsive to end-users. There are three different ways to stream with graphs: by [values](../how_tos/cloud_examples/stream_values/), by [messages](../how_tos/cloud_examples/stream_messages/), and by [updates](../how_tos/cloud_examples/stream_updates/).
## Human-in-the-Loop
There are many occasions where the graph cannot run completely autonomously. For instance, the user might need to input some additional arguments to a function call, or select the next edge for the graph to continue on. In these instances, we need to insert some human in the loop interaction, which you can learn about in [this how-to](../how_tos/cloud_examples/human-in-the-loop_cloud).
## Multi-Tasking
Many times users might interact with your graph in unintended ways. For instance, a user interacting with a graph that has chat output could send one message and before the graph has finished running send a second message. To solve this issue of "double-texting" (i.e. prompting the graph a second time before the first run has finished), Langgraph has provided four different solutions, all of which are covered in the [Double Texting how-tos](../how_tos/cloud_examples/interrupt_concurrent/).
Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

+157
View File
@@ -0,0 +1,157 @@
# Deploy custom LangGraph code with LangGraph Cloud (Python)
## Set up your application code
### Create a new application
To create a new app called <my-app> create a directory with the following structure
```
<my-app>/
|-- agent.py # code for your LangGraph agent
|-- requirements.txt # python packages required for your graph
|-- langgraph.json # configuration file for langgraph
|-- .env # environment files with API keys
```
### Agent File
In your agent file, you can define as many graphs (agents) as you would like. For our example we are going to create the simplest graph possible: a one node graph. You can read about adding more complexity to your graphs in the [docs](https://langchain-ai.github.io/langgraph/tutorials/introduction/).
Here is what our `agent.py` file looks like for this example:
```python
from langchain_openai import ChatOpenAI
from langgraph.graph import END, MessageGraph
model = ChatOpenAI(temperature=0)
graph_workflow = MessageGraph()
graph_workflow.add_node("oracle", model)
graph_workflow.add_edge("oracle", END)
graph_workflow.set_entry_point("oracle")
graph = graph_workflow.compile()
```
### Configuration file
- `langgraph.json` is a configuration file with three parts:
- `graphs`
- Pass in the graphs you want to host on your deployment, using the graph_id as the key and the path to the agent (a CompiledGraph) as the value. In our example we only use one graph, so the json looks like so:
```json
"graphs": {
"agent": "./agent.py:graph"
},
```
- `dependencies`
- Pass in a list of the dependencies you would like to be installed in order to host your app. In our case, we dont need any additional dependencies besides our `requirements.txt` file, but if we did we could append them to the dependencies list using the names of the additional packages we want installed.
```json
"dependencies": ["."],
```
- `env`
- This is simply a path to our environment file containing all variables/files to load.
```json
"env": ".env"
```
Putting it all together, our `langgraph.json` file should look like this:
```json
{
"dependencies": ["."],
"graphs": {
"agent": "./agent.py:agent"
},
"env": ".env"
}
```
### Environment and Package Requirement files
- The `.env` contains any environment variables that are needed to run your code. In our example the file looks like follows:
```python
OPENAI_API_KEY= ...
LANGCHAIN_API_KEY= ...
LANGCHAIN_TRACING_V2=true
```
- The `requirements.txt` file lists python package dependencies for your project (along with the associated versions if necessary). In our example the file looks like this:
```
langgraph
langchain_openai
```
### Push your code to GitHub
Create a git repo in the `<my-app>` directory, and verify its existence. You can use the GitHub CLI if you like, or just create a repo manually.
## Host your code on LangGraph Cloud
### Deploy from GitHub with LangGraph Cloud
Head to LangSmith and click on the 🚀 icon on the left navbar to create a new deployment. Click the `+ New Deployment` button.
***If you have not deployed to LangGraph Cloud before:*** there will be a button that shows up saying Import from GitHub. Youll need to follow that flow to connect LangGraph Cloud to GitHub.
***Once you have set up your GitHub connection:*** the new deployment page will look as follows
![Screenshot 2024-06-11 at 1.17.03PM.png](./img/deployment_page.png)
To deploy your application, you should do the following:
1. Select your GitHub username or organization from the selector
2. Search for your repo to deploy in the search bar and select it
3. Choose any name
4. In the `LangGraph API config file` field, enter the path to your `langgraph.json` file (if left blank langsmith will automatically search for it on deployment)
5. For Git Reference, you can select either the git branch for the code you want to deploy, or the exact commit SHA.
6. If your chain relies on environment variables (for example, an OPENAI_API_KEY), add those in. They will be propagated to the underlying server so your code can access them.
Putting this all together, you should have something as follows for your deployment details:
![Screenshot 2024-06-11 at 1.21.52PM.png](./img/deploy_filled_out.png)
Hit `Submit` and your application will start deploying!
## Inspect Traces + Monitor Service
### Deployments View
After your deployment is complete, your deployments page should look as follows:
![Screenshot 2024-06-11 at 2.03.34PM.png](./img/deployed_page.png)
You can see that by default, you get access to the `Trace Count` monitoring chart and `Recent Traces` run view. These are powered by LangSmith.
You can click on `All Charts` to view all monitoring info for your server, or click on `See tracing project` to get more information on an individual trace.
### Access the Docs
You can access the docs by clicking on the API DOCS link, which should send you to a page that looks like this:
![Screenshot 2024-06-19 at 2.27.24PM.png](./img/api_page.png)
You wont actually be able to test any of the API endpoints without authorizing first. To do so, click on the Authorize button in the top right corner, input your `LANGCHAIN_API_KEY` in the `API Key` box, and then click `Authorize` to finish the process. You should now be able to select any of the API endpoints, click `Try it out` , enter the parameters you would like to pass, and then click `Execute` to view the results of the API call.
## Interact with your deployment via LangGraph Studio
### Access Studio
If you click on your deployment you should see a blue button in the top right that says `LangGraph Studio`. Clicking on this button will take you to a page that looks like this:
![Screenshot 2024-06-11 at 2.51.51PM.png](./img/graph_visualiztion)
On this page you can test out your graph by passing in starting states and clicking `Start Run` (this should behave identically to calling `.invoke`). You will then be able to look into the execution thread for each run and explore the steps your graph is taking to produce its output.
## Deploy new code
To deploy new code that you push to GitHub, simply navigate to the deployments page, and hit `+ New Revision`. LangGraph Cloud releases what it calls a new “revision” every time you deploy code. Therefore, your first deployment automatically showed revisions. A Revision always corresponds to a new piece of code being deployed. A modal will pop up to enter new revision info. This can be thought of as a partial update on the last revision, so you do not need to enter any fields that didnt change (*note: environment variables are not saved between revisions, you must re-enter them for each new revision)*.
@@ -0,0 +1,9 @@
### Run your server locally
First, make sure that Docker is up and running. Test that your server works by running:
```python
langgraph up -c langgraph.json
```
This will bring up a local server with your graph! Access the auto-generated server for your playground to confirm everything works as planned at [http://localhost:8124](http://localhost:8124) .
+11
View File
@@ -0,0 +1,11 @@
# LangGraph Cloud (alpha)
!!! danger "Important"
LangGraph Cloud is a closed source, paid product in closed alpha stage. Self-hosting LangGraph Cloud applications is only permitted with explicit approval from LangChain.
!!! warning "Under Construction"
LangGraph Cloud documentation is under construction. Contents may change until general availability.
LangGraph Cloud is a managed service for deploying and hosting LangGraph applications. Deploying your application with LangGraph Cloud shortens the time-to-market for developers. With one click, start a production-ready HTTP microservice with built-in persistence for your LangGraph application.
LangGraph Cloud is seamlessly integrated with [LangSmith](https://www.langchain.com/langsmith) and is accessible from within the LangSmith UI.
+70
View File
@@ -0,0 +1,70 @@
# Quick Start
This quick start guide will cover how to develop an application for LangGraph Cloud, run it locally in Docker, and call the APIs to invoke a graph.
Alternatively, clone or fork the [`langgraph/example`](https://github.com/langchain-ai/langgraph-example) GitHub repository and follow the instructions in the `README`.
## Develop
1. Create a new application with the following directory and files:
<my-app>/
|-- agent.py # code for your LangGraph agent
|-- requirements.txt # Python packages required for your graph
|-- langgraph.json # configuration file for LangGraph
|-- .env # environment files with API keys
2. The `agent.py` file should contain the following Python code for defining a simple graph:
```python
from langchain_openai import ChatOpenAI
from langgraph.graph import END, MessageGraph
model = ChatOpenAI(temperature=0)
graph_workflow = MessageGraph()
graph_workflow.add_node("agent", model)
graph_workflow.add_edge("agent", END)
graph_workflow.set_entry_point("agent")
graph = graph_workflow.compile()
```
3. The `requirements.txt` file should contain the following dependencies:
langgraph
langchain_openai
4. The `langgraph.json` file should contain the following JSON object:
```json
{
"dependencies": ["."],
"graphs": {
"agent": "./agent.py:graph"
},
"env": ".env"
}
```
Learn more about the LangGraph CLI configuration file [here](./reference/cli.md#configuration-file).
5. The `.env` file should contain the environment variables:
OPENAI_API_KEY=<add your key here>
LANGGRAPH_AUTH_TYPE=noop
!!! warning "Disable Authentication"
When testing locally, set `LANGGRAPH_AUTH_TYPE` to `noop` to disable authentication.
## Run Locally
1. Install the [LangGraph CLI](./reference/cli.md#installation).
2. Run the following command to start the API server in Docker:
langgraph up -c langgraph.json
3. The API server is now running at `http://localhost:8123`. Navigate to [`http://localhost:8123/docs`](http://localhost:8123/docs) to view the API docs.
## Deploy to Cloud
Follow [these instructions](./deployment/managed.md#deploy-from-github-with-hosted-langgraph) to deploy to LangGraph Cloud.
+2
View File
@@ -0,0 +1,2 @@
# API Reference
Coming soon
+142
View File
@@ -0,0 +1,142 @@
# LangGraph CLI
The LangGraph CLI includes commands to build and run a LangGraph Cloud server locally in [Docker](https://www.docker.com/). For development and testing, use the CLI to deploy a local API server.
## Installation
1. Ensure that Docker is installed (e.g. `docker --version`).
1. Install the `langgraph-cli` Python package (e.g. `pip install langgraph-cli`).
1. Run the command `langgraph --help` to confirm that the CLI is installed.
## Configuration File
The LangGraph CLI requires a JSON configuration file with the following keys:
| Key | Description |
| --- | ----------- |
| `dependencies` | **Required**. Array of dependencies for LangGraph Deploy API server. Dependencies can be one of the following: (1) `"."`, which will look for local Python packages, (2) `pyproject.toml`, `setup.py` or `requirements.txt` in the app directory `"./local_package"`, or (3) a package name. |
| `graphs` | **Required**. Mapping from graph ID to path where the compiled graph is defined. Example: `./your_package/your_file.py:variable`, where `variable` is an instance of `langgraph.graph.graph.CompiledGraph`. |
| `env` | Path to `.env` file or a mapping from environment variable to its value. |
| `python_version` | `3.11` or `3.12`. Defaults to `3.11`. |
| `pip_config_file`| Path to `pip` config file. |
| `dockerfile_lines` | Array of additional lines to add to Dockerfile following the import from parent image. |
<div class="admonition tip">
<p class="admonition-title">Note</p>
<p>
The LangGraph CLI defaults to using the configuration file <strong>langgraph.json</strong> in the current directory.
</p>
</div>
Example:
```json
{
"dependencies": [
"langchain_openai",
"./your_package"
],
"graphs": {
"my_graph_id": "./your_package/your_file.py:variable"
},
"env": "./.env"
}
```
Example:
```json
{
"python_version": "3.11",
"dependencies": [
"langchain_openai",
"."
],
"graphs": {
"my_graph_id": "./your_package/your_file.py:variable"
},
"env": {
"OPENAI_API_KEY": "secret-key"
}
}
```
## Commands
The base command for the LangGraph CLI is `langgraph`.
**Usage**
```
langgraph [OPTIONS] COMMAND [ARGS]
```
### `build`
Build LangGraph Deploy API server Docker image.
**Usage**
```
langgraph build [OPTIONS]
```
**Options**
| Option | Default | Description |
| ------ | ------- | ----------- |
| `--platform TEXT` | | Target platform(s) to build the Docker image for. Example: `langgraph build --platform linux/amd64,linux/arm64` |
| `-t, --tag TEXT` | | **Required**. Tag for the Docker image. Example: `langgraph build -t my-image` |
| `--pull / --no-pull` | `--pull` | Build with latest remote Docker image. Use `--no-pull` for running the LangGraph Deploy API server with locally built images. |
| `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. |
| `--help` | | Display command documentation. |
### `down`
Stop LangGraph Deploy API server.
**Usage**
```
langgraph down [OPTIONS]
```
**Options**
| Option | Default | Description |
| ------ | ------- | ----------- |
| `--debugger-port INTEGER` | | Pull the debugger image locally and serve the UI on specified port. |
| `--verbose` | | Show more output from the server logs. |
| `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. |
| `-d, --docker-compose FILE` | | Advanced. Path to `docker-compose.yml` file with additional services to launch. |
| `-p, --port INTEGER` | `8123` | Port to expose. Example: `langgraph up --port 8000` |
| `--help` | | Display command documentation. |
### `logs`
Show LangGraph Deploy API server logs.
**Usage**
```
langgraph logs [OPTIONS]
```
**Options**
| Option | Default | Description |
| ------ | ------- | ----------- |
| `-f, --follow` | | Follow logs. |
| `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. |
| `-d, --docker-compose FILE` | | Advanced. Path to `docker-compose.yml` file with additional services to launch. |
| `--help` | | Display command documentation. |
### `up`
Start LangGraph Deploy API server.
**Usage**
```
langgraph up [OPTIONS]
```
**Options**
| Option | Default | Description |
| ------ | ------- | ----------- |
| `--wait` | | Wait for services to start before returning. Implies `--detach`. |
| `--watch` | | Restart on file changes. |
| `--debugger-port INTEGER` | | Pull the debugger image locally and serve the UI on specified port. |
| `--verbose` | | Show more output from the server logs. |
| `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. |
| `-d, --docker-compose FILE` | | Advanced. Path to `docker-compose.yml` file with additional services to launch. |
| `-p, --port INTEGER` | `8123` | Port to expose. Example: `langgraph up --port 8000` |
| `--pull / --no-pull` | `--pull` | Build with latest remote Docker image. Use `--no-pull` for running the LangGraph Deploy API server with locally built images. |
| `--recreate / --no-recreate` | `--no-recreate` | Recreate containers even if their configuration and image haven't changed. |
| `--help` | | Display command documentation. |
@@ -0,0 +1,2 @@
# JS/TS SDK Reference
Coming soon
@@ -0,0 +1,2 @@
# Python SDK Reference
Coming soon
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB