Building Langgraph API server - dhs-shine/open-canvas GitHub Wiki

Prerequisites

Installing langgraph-cli

mkdir ~/.venv
python3 -m venv ~/.venv/langgraph
. ~/.venv/langgraph/bin/activate
pip install langgraph-cli

Installing docker

How to build

. ~/.venv/langgraph/bin/activate
cd ~/Workspace/open-canvas
langgraph build -c langgraph.json -t my-first-langgraph-api-server
(langgraph) dhsshin@DESKTOP-603R0O2:~/Workspace/open-canvas$ langgraph build -c langgraph.json -t my-first-langgraph-api-server
| Pulling...+ docker pull langchain/langgraphjs-api:20
\ Pulling...20: Pulling from langchain/langgraphjs-api
Digest: sha256:393ff9c4129f53d2b486d8bf8fc5d6e031ee031cbd8cda5fc2702f762890839d
Status: Image is up to date for langchain/langgraphjs-api:20
docker.io/langchain/langgraphjs-api:20
+ docker build -f - -t my-first-langgraph-api-server /home/dhsshin/Workspace/open-canvas <
FROM langchain/langgraphjs-api:20
ADD . /deps/open-canvas
RUN cd /deps/open-canvas && yarn install --frozen-lockfile
ENV LANGSERVE_GRAPHS='{"agent": "./src/agent/open-canvas/index.ts:graph", "reflection": "./src/agent/reflection/index.ts:graph", "thread_title": "./src/agent/thread-title/index.ts:graph"}'
WORKDIR /deps/open-canvas
RUN (test ! -f /api/langgraph_api/js/build.mts && echo "Prebuild script not found, skipping") || tsx /api/langgraph_api/js/build.mts
\ Building...#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 510B done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/langchain/langgraphjs-api:20
#2 DONE 0.0s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [1/5] FROM docker.io/langchain/langgraphjs-api:20@sha256:393ff9c4129f53d2b486d8bf8fc5d6e031ee031cbd8cda5fc2702f762890839d
#4 resolve docker.io/langchain/langgraphjs-api:20@sha256:393ff9c4129f53d2b486d8bf8fc5d6e031ee031cbd8cda5fc2702f762890839d 0.0s done
#4 DONE 0.0s

#5 [internal] load build context
| Building...#5 transferring context: 7.25MB 2.6s done
- Building...#5 DONE 2.7s

#4 [1/5] FROM docker.io/langchain/langgraphjs-api:20@sha256:393ff9c4129f53d2b486d8bf8fc5d6e031ee031cbd8cda5fc2702f762890839d
#4 CACHED

#6 [2/5] ADD . /deps/open-canvas
\ Building...#6 DONE 12.1s
/ Building...
#7 [3/5] RUN cd /deps/open-canvas && yarn install --frozen-lockfile
| Building...#7 0.526 ! Corepack is about to download https://repo.yarnpkg.com/4.2.2/packages/yarnpkg-cli/bin/yarn.js
- Building...#7 1.106 โžค YN0050: The --frozen-lockfile option is deprecated; use --immutable and/or --immutable-cache instead
\ Building...#7 1.106 
#7 1.217 โžค YN0000: ยท Yarn 4.2.2
/ Building...#7 1.230 โžค YN0000: โ”Œ Resolution step
#7 1.399 โžค YN0000: โ”” Completed
\ Building...#7 1.401 โžค YN0000: โ”Œ Post-resolution validation
#7 1.401 โžค YN0060: โ”‚ @vercel/kv is listed by your project with version 2.0.0, which doesn't satisfy what @langchain/community (pc94f9) requests (~0.2.3).
#7 1.401 โžค YN0060: โ”‚ react is listed by your project with version 18.3.1, which doesn't satisfy what react-json-view (paf38f) and other dependencies request (^15.5.4 || ^16.3.0 || ^17.0.0).
#7 1.401 โžค YN0060: โ”‚ react-dom is listed by your project with version 18.3.1, which doesn't satisfy what react-json-view (p51a40) requests (^17.0.0 || ^16.3.0 || ^15.5.4).
#7 1.401 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @codemirror/autocomplete (pe74d0), requested by @replit/codemirror-lang-csharp.
#7 1.401 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @codemirror/language (p99d93), requested by @replit/codemirror-lang-csharp.
#7 1.402 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @codemirror/state (p07735), requested by @replit/codemirror-lang-csharp.
#7 1.402 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @codemirror/view (p70bce), requested by @uiw/react-codemirror.
#7 1.402 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @codemirror/view (pbba7f), requested by @replit/codemirror-lang-csharp.
#7 1.402 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @ibm-cloud/watsonx-ai (p41c5e), requested by @langchain/community.
#7 1.402 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @lezer/common (p63806), requested by @replit/codemirror-lang-csharp.
#7 1.402 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @lezer/highlight (p98721), requested by @replit/codemirror-lang-csharp.
#7 1.402 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide @lezer/lr (p94552), requested by @replit/codemirror-lang-csharp.
#7 1.402 โžค YN0002: โ”‚ open_canvas@workspace:. doesn't provide ibm-cloud-sdk-core (p16bb6), requested by @langchain/community.
#7 1.402 โžค YN0086: โ”‚ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
#7 1.434 โžค YN0000: โ”” Completed
#7 1.435 โžค YN0000: โ”Œ Fetch step
| Building...#7 15.30 โžค YN0066: โ”‚ typescript@patch:typescript@npm%3A5.5.4#optional!builtin<compat/typescript>::version=5.5.4&hash=b45daf: Cannot apply hunk #11
/ Building...#7 18.25 โžค YN0013: โ”‚ 1036 packages were added to the project (+ 737.49 MiB).
\ Building...#7 18.25 โžค YN0000: โ”” Completed in 16s 815ms
#7 18.29 โžค YN0000: โ”Œ Link step
- Building...#7 18.70 โžค YN0008: โ”‚ esbuild@npm:0.23.1 must be rebuilt because its dependency tree changed
\ Building...#7 18.81 โžค YN0000: โ”” Completed in 0s 521ms
/ Building...#7 18.87 โžค YN0000: ยท Done with warnings in 17s 657ms
- Building...#7 DONE 19.1s
| Building...
#8 [4/5] WORKDIR /deps/open-canvas
#8 DONE 0.0s

#9 [5/5] RUN (test ! -f /api/langgraph_api/js/build.mts && echo "Prebuild script not found, skipping") || tsx /api/langgraph_api/js/build.mts
\ Building...#9 0.507 [agent]: Checking for source file existence
/ Building...#9 0.508 [reflection]: Checking for source file existence
#9 0.508 [thread_title]: Checking for source file existence
#9 0.509 [agent]: Extracting schema
#9 0.511 [reflection]: Extracting schema
#9 0.512 [thread_title]: Extracting schema
- Building...#9 13.83 Failed to obtain symbol "__langgraph__graph_generateTitle__input": Unsupported type: never
/ Building...#9 13.84 Failed to obtain symbol "__langgraph__graph_generateTitle__output": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_generateTitle__update": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_generateTitle__config": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_reflect__input": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_reflect__output": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_reflect__update": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_reflect__config": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_generateFollowup__input": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_generateFollowup__output": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_generateFollowup__update": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_generateFollowup__config": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_customAction__input": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_customAction__output": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_customAction__update": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_customAction__config": Unsupported type: never
#9 13.84 Failed to obtain symbol "__langgraph__graph_generateArtifact__input": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_generateArtifact__output": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_generateArtifact__update": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_generateArtifact__config": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_updateHighlightedText__input": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_updateHighlightedText__output": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_updateHighlightedText__update": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_updateHighlightedText__config": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_updateArtifact__input": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_updateArtifact__output": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_updateArtifact__update": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_updateArtifact__config": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteCodeArtifactTheme__input": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteCodeArtifactTheme__output": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteCodeArtifactTheme__update": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteCodeArtifactTheme__config": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteArtifactTheme__input": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteArtifactTheme__output": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteArtifactTheme__update": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteArtifactTheme__config": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteArtifact__input": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteArtifact__output": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteArtifact__update": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_rewriteArtifact__config": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_replyToGeneralInput__input": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_replyToGeneralInput__output": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_replyToGeneralInput__update": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_replyToGeneralInput__config": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_generatePath__input": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_generatePath__output": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_generatePath__update": Unsupported type: never
#9 13.85 Failed to obtain symbol "__langgraph__graph_generatePath__config": Unsupported type: never
#9 13.85 All graphs resolved
#9 DONE 13.9s

#10 exporting to image
#10 exporting layers
/ Building...#10 exporting layers 20.2s done
\ Building...#10 exporting manifest sha256:145014f18bb0150fcd3fec019834a6d12ff4c4515bf7f54e5294732f3bb6e09e done
#10 exporting config sha256:26f305674606cc4d6156fa74d474395879830a5ae5cbe6de9f6627ffa53e58c0 done
#10 exporting attestation manifest sha256:21b65a51a74267b8657d9d490bef30a42c1d14eca5624ff5db6d751972111a58 0.0s done
#10 exporting manifest list sha256:d2bee1365fb884c3585c7871feabb1b4ba5c038862688c906001be977811141e done
#10 naming to docker.io/library/my-first-langgraph-api-server:latest done
#10 unpacking to docker.io/library/my-first-langgraph-api-server:latest
\ Building...#10 unpacking to docker.io/library/my-first-langgraph-api-server:latest 16.0s done
| Building...#10 DONE 36.2s

Langgraph cloud api source?

(langgraph) dhsshin@DESKTOP-603R0O2:~/Workspace/open-canvas$ docker run -tdi my-first-langgraph-api-server:latest bash
c3da4fb5e33086016263e01cc064a080da5699c3e053f1819297aceecea632f0
(langgraph) dhsshin@DESKTOP-603R0O2:~/Workspace/open-canvas$ docker ps -a
CONTAINER ID   IMAGE                                  COMMAND   CREATED          STATUS                      PORTS     NAMES
c3da4fb5e330   my-first-langgraph-api-server:latest   "bash"    48 seconds ago   Up 47 seconds (unhealthy)             inspiring_euler
(langgraph) dhsshin@DESKTOP-603R0O2:~/Workspace/open-canvas$ docker exec -it inspiring_euler bash
root@c3da4fb5e330:/deps/open-canvas# ls
LICENSE  README.md  components.json  evals  langgraph.json  next-env.d.ts  next.config.mjs  node_modules  package.json  postcss.config.mjs  public  src  tailwind.config.ts  tsconfig.json  yarn.lock
root@c3da4fb5e330:~# cd /api/
root@c3da4fb5e330:/api# ls
Dockerfile       Makefile   benchmark    constraints-license.txt  constraints.txt  healthcheck.pyc  logging.json  poetry.lock     scripts
Dockerfile.node  README.md  compose.yml  constraints-storage.txt  healthcheck.py   langgraph_api    openapi.json  pyproject.toml  tests
root@c3da4fb5e330:/api# cd /api/
root@c3da4fb5e330:/api# ls
Dockerfile       Makefile   benchmark    constraints-license.txt  constraints.txt  healthcheck.pyc  logging.json  poetry.lock     scripts
Dockerfile.node  README.md  compose.yml  constraints-storage.txt  healthcheck.py   langgraph_api    openapi.json  pyproject.toml  tests
root@c3da4fb5e330:/api# cd langgraph_api/
root@c3da4fb5e330:/api/langgraph_api# ls
__init__.pyc  api  auth  config.pyc  cron_scheduler.pyc  http.pyc  js  lifespan.pyc  metadata.pyc  models  patch.pyc  queue.pyc  server.pyc  shared
root@c3da4fb5e330:/api/langgraph_api# cd api/
root@c3da4fb5e330:/api/langgraph_api/api# ls
__init__.pyc  assistants.pyc  meta.pyc  openapi.pyc  runs.pyc  store.pyc  threads.pyc
root@c3da4fb5e330:/api/langgraph_api/api# tree
.
โ”œโ”€โ”€ __init__.pyc
โ”œโ”€โ”€ assistants.pyc
โ”œโ”€โ”€ meta.pyc
โ”œโ”€โ”€ openapi.pyc
โ”œโ”€โ”€ runs.pyc
โ”œโ”€โ”€ store.pyc
โ””โ”€โ”€ threads.pyc

1 directory, 7 files
root@c3da4fb5e330:/api/langgraph_api/api# cd ..
root@c3da4fb5e330:/api/langgraph_api# ls
__init__.pyc  api  auth  config.pyc  cron_scheduler.pyc  http.pyc  js  lifespan.pyc  metadata.pyc  models  patch.pyc  queue.pyc  server.pyc  shared
root@c3da4fb5e330:/api/langgraph_api# cd models/
root@c3da4fb5e330:/api/langgraph_api/models# ls
__init__.pyc  run.pyc
root@c3da4fb5e330:/api/langgraph_api/models# tree
.
โ”œโ”€โ”€ __init__.pyc
โ””โ”€โ”€ run.pyc

1 directory, 2 files
root@c3da4fb5e330:/api/langgraph_api/models# cd ..
root@c3da4fb5e330:/api/langgraph_api# ls
__init__.pyc  api  auth  config.pyc  cron_scheduler.pyc  http.pyc  js  lifespan.pyc  metadata.pyc  models  patch.pyc  queue.pyc  server.pyc  shared
root@c3da4fb5e330:/api/langgraph_api# cd auth/
root@c3da4fb5e330:/api/langgraph_api/auth# ls
__init__.pyc  langsmith  middleware.pyc  noop.pyc
root@c3da4fb5e330:/api/langgraph_api/auth# tree
.
โ”œโ”€โ”€ __init__.pyc
โ”œโ”€โ”€ langsmith
โ”‚   โ”œโ”€โ”€ __init__.pyc
โ”‚   โ”œโ”€โ”€ backend.pyc
โ”‚   โ””โ”€โ”€ client.pyc
โ”œโ”€โ”€ middleware.pyc
โ””โ”€โ”€ noop.pyc

2 directories, 6 files
root@c3da4fb5e330:/api/langgraph_api/auth# 
โš ๏ธ **GitHub.com Fallback** โš ๏ธ