Skip to content

Commit d9c66b4

Browse files
authored
switch to hosted langgraph (#328)
* relax langgraph constraint * update github actions to deploy only frontend * bump sdk and pass api key * pass api key to gha
1 parent e34776e commit d9c66b4

File tree

7 files changed

+333
-424
lines changed

7 files changed

+333
-424
lines changed

.github/workflows/deploy-cloud-run.yaml

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,88 +5,16 @@ on:
55
branches: [master]
66
workflow_dispatch:
77

8-
env:
9-
POETRY_VERSION: "1.7.1"
10-
PYTHON_VERSION: "3.11"
11-
128
jobs:
13-
deploy-backend:
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v3
19-
20-
- name: Set up Short Hash
21-
run: |
22-
echo "GIT_SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
23-
echo "LC_ENVIRONMENT=dev" >> $GITHUB_ENV
24-
25-
- name: Set up Python ${{ env.PYTHON_VERSION }} + Poetry ${{ env.POETRY_VERSION }}
26-
uses: "./.github/actions/poetry_setup"
27-
with:
28-
python-version: ${{ env.PYTHON_VERSION }}
29-
poetry-version: ${{ env.POETRY_VERSION }}
30-
cache-key: lint
31-
32-
- name: Set up depot.dev multi-arch runner
33-
uses: depot/setup-action@v1
34-
35-
- name: Login to DockerHub
36-
uses: docker/login-action@v2
37-
with:
38-
username: ${{ secrets.DOCKERHUB_USERNAME }}
39-
password: ${{ secrets.DOCKERHUB_TOKEN }}
40-
41-
- name: Set up Docker Buildx
42-
uses: docker/setup-buildx-action@v3
43-
44-
- name: Build and push
45-
run: |
46-
pip install langgraph-cli
47-
langgraph build -t docker.io/langchain/chat-langchain-backend:${{ env.GIT_SHORT_SHA }}
48-
docker push docker.io/langchain/chat-langchain-backend:${{ env.GIT_SHORT_SHA }}
49-
50-
- name: Checkout deployments repo
51-
uses: actions/checkout@v3
52-
with:
53-
repository: langchain-ai/deployments
54-
path: deployments
55-
token: ${{ secrets.DEPLOYMENTS_PAT }}
56-
57-
- name: Update Docker image in Terraform files (dev)
58-
run: |
59-
cd deployments/environments/gcp/chat-langchain
60-
# Modify the main.tf terraform file
61-
sed -i "s|image_tag = \"docker.io/langchain/chat-langchain-backend:[^\"]*\"|image_tag = \"docker.io/langchain/chat-langchain-backend:${{ env.GIT_SHORT_SHA }}\"|" main.tf
62-
63-
- name: Create Pull Request
64-
id: create-pr
65-
uses: peter-evans/create-pull-request@v5
66-
with:
67-
token: ${{ secrets.DEPLOYMENTS_PAT }}
68-
title: "Update Chat Langchain Docker image to ${{ env.GIT_SHORT_SHA }}"
69-
commit-message: "Update Docker image"
70-
base: "main"
71-
branch: "actions/update-docker-image-${{ env.GIT_SHORT_SHA }}"
72-
body: 'Update Chat Langchain Docker image to ${{ env.GIT_SHORT_SHA }}'
73-
path: deployments
74-
75-
- name: Enable Pull Request Automerge
76-
uses: peter-evans/enable-pull-request-automerge@v3
77-
with:
78-
token: ${{ secrets.DEPLOYMENTS_PAT }}
79-
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }}
80-
repository: langchain-ai/deployments
81-
829
deploy-frontend:
8310
name: Deploy Frontend to Vercel
8411
runs-on: ubuntu-latest
8512
environment: Production
86-
needs: deploy-backend
8713
env:
8814
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
8915
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
16+
NEXT_PUBLIC_API_BASE_URL: ${{ secrets.NEXT_PUBLIC_API_BASE_URL }}
17+
NEXT_PUBLIC_LANGCHAIN_API_KEY: ${{ secrets.NEXT_PUBLIC_LANGCHAIN_API_KEY }}
9018
steps:
9119
- uses: actions/checkout@v2
9220
- name: Install Vercel CLI

frontend/app/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import { Client } from "@langchain/langgraph-sdk";
77

88
import { ChatWindow } from "./components/ChatWindow";
99
import { LangGraphClientContext } from "./hooks/useLangGraphClient";
10-
import { apiBaseUrl } from "./utils/constants";
10+
import { API_BASE_URL, LANGCHAIN_API_KEY } from "./utils/constants";
1111

1212
export default function Home() {
1313
const queryClient = new QueryClient();
14-
const langGraphClient = new Client({ apiUrl: apiBaseUrl });
14+
const langGraphClient = new Client({
15+
apiUrl: API_BASE_URL,
16+
defaultHeaders: { "x-api-key": LANGCHAIN_API_KEY },
17+
});
1518
return (
1619
<LangGraphClientContext.Provider value={langGraphClient}>
1720
<QueryClientProvider client={queryClient}>

frontend/app/utils/constants.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
export const apiBaseUrl =
1+
export const API_BASE_URL =
22
process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://localhost:8123";
3+
export const LANGCHAIN_API_KEY = process.env.NEXT_PUBLIC_LANGCHAIN_API_KEY;
34

45
export const RESPONSE_FEEDBACK_KEY = "user_score";
56
export const SOURCE_CLICK_KEY = "user_click";

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@emotion/react": "^11.11.1",
1717
"@emotion/styled": "^11.11.0",
1818
"@langchain/core": "^0.1.27",
19-
"@langchain/langgraph-sdk": "^0.0.1-rc.7",
19+
"@langchain/langgraph-sdk": "^0.0.1-rc.11",
2020
"@types/dompurify": "^3.0.5",
2121
"@types/lodash.orderby": "^4.6.9",
2222
"@types/marked": "^5.0.1",

frontend/yarn.lock

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,11 +1108,12 @@
11081108
zod "^3.22.4"
11091109
zod-to-json-schema "^3.22.3"
11101110

1111-
"@langchain/langgraph-sdk@^0.0.1-rc.7":
1112-
version "0.0.1-rc.7"
1113-
resolved "https://registry.yarnpkg.com/@langchain/langgraph-sdk/-/langgraph-sdk-0.0.1-rc.7.tgz#d1f5f23937a86219e298b8fa33b80b3d998a4177"
1114-
integrity sha512-d6wzMxvB0R40gs340aVS0a+o9DvcsQqtBoS4s6LGfZxlHB7CbLiflPEaM/3fKeEziLTxmYl2BWOfHsjwiMwOgQ==
1111+
"@langchain/langgraph-sdk@^0.0.1-rc.11":
1112+
version "0.0.1-rc.11"
1113+
resolved "https://registry.yarnpkg.com/@langchain/langgraph-sdk/-/langgraph-sdk-0.0.1-rc.11.tgz#60488ea8e3be89f6eae698b953e4092553cc112c"
1114+
integrity sha512-KddqkTxkzaPEoOm/4CklHkSyHCnHWDNotAtFJucGTpJ1ONgLaTtvkqhbdam7V/SUkoFVd1+8FHCskPhUH8nMlQ==
11151115
dependencies:
1116+
"@types/json-schema" "^7.0.15"
11161117
eventsource-parser "^1.1.2"
11171118
p-queue "^6.6.2"
11181119
p-retry "4"
@@ -1225,6 +1226,11 @@
12251226
dependencies:
12261227
"@types/trusted-types" "*"
12271228

1229+
"@types/json-schema@^7.0.15":
1230+
version "7.0.15"
1231+
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
1232+
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
1233+
12281234
"@types/json5@^0.0.29":
12291235
version "0.0.29"
12301236
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"

0 commit comments

Comments
 (0)