Skip to content

Commit

Permalink
switch to hosted langgraph (langchain-ai#328)
Browse files Browse the repository at this point in the history
* relax langgraph constraint

* update github actions to deploy only frontend

* bump sdk and pass api key

* pass api key to gha
  • Loading branch information
vbarda authored Jun 14, 2024
1 parent e34776e commit d9c66b4
Show file tree
Hide file tree
Showing 7 changed files with 333 additions and 424 deletions.
76 changes: 2 additions & 74 deletions .github/workflows/deploy-cloud-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,88 +5,16 @@ on:
branches: [master]
workflow_dispatch:

env:
POETRY_VERSION: "1.7.1"
PYTHON_VERSION: "3.11"

jobs:
deploy-backend:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Short Hash
run: |
echo "GIT_SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "LC_ENVIRONMENT=dev" >> $GITHUB_ENV
- name: Set up Python ${{ env.PYTHON_VERSION }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
with:
python-version: ${{ env.PYTHON_VERSION }}
poetry-version: ${{ env.POETRY_VERSION }}
cache-key: lint

- name: Set up depot.dev multi-arch runner
uses: depot/setup-action@v1

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
run: |
pip install langgraph-cli
langgraph build -t docker.io/langchain/chat-langchain-backend:${{ env.GIT_SHORT_SHA }}
docker push docker.io/langchain/chat-langchain-backend:${{ env.GIT_SHORT_SHA }}
- name: Checkout deployments repo
uses: actions/checkout@v3
with:
repository: langchain-ai/deployments
path: deployments
token: ${{ secrets.DEPLOYMENTS_PAT }}

- name: Update Docker image in Terraform files (dev)
run: |
cd deployments/environments/gcp/chat-langchain
# Modify the main.tf terraform file
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
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.DEPLOYMENTS_PAT }}
title: "Update Chat Langchain Docker image to ${{ env.GIT_SHORT_SHA }}"
commit-message: "Update Docker image"
base: "main"
branch: "actions/update-docker-image-${{ env.GIT_SHORT_SHA }}"
body: 'Update Chat Langchain Docker image to ${{ env.GIT_SHORT_SHA }}'
path: deployments

- name: Enable Pull Request Automerge
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.DEPLOYMENTS_PAT }}
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }}
repository: langchain-ai/deployments

deploy-frontend:
name: Deploy Frontend to Vercel
runs-on: ubuntu-latest
environment: Production
needs: deploy-backend
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
NEXT_PUBLIC_API_BASE_URL: ${{ secrets.NEXT_PUBLIC_API_BASE_URL }}
NEXT_PUBLIC_LANGCHAIN_API_KEY: ${{ secrets.NEXT_PUBLIC_LANGCHAIN_API_KEY }}
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
Expand Down
7 changes: 5 additions & 2 deletions frontend/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import { Client } from "@langchain/langgraph-sdk";

import { ChatWindow } from "./components/ChatWindow";
import { LangGraphClientContext } from "./hooks/useLangGraphClient";
import { apiBaseUrl } from "./utils/constants";
import { API_BASE_URL, LANGCHAIN_API_KEY } from "./utils/constants";

export default function Home() {
const queryClient = new QueryClient();
const langGraphClient = new Client({ apiUrl: apiBaseUrl });
const langGraphClient = new Client({
apiUrl: API_BASE_URL,
defaultHeaders: { "x-api-key": LANGCHAIN_API_KEY },
});
return (
<LangGraphClientContext.Provider value={langGraphClient}>
<QueryClientProvider client={queryClient}>
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/utils/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const apiBaseUrl =
export const API_BASE_URL =
process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://localhost:8123";
export const LANGCHAIN_API_KEY = process.env.NEXT_PUBLIC_LANGCHAIN_API_KEY;

export const RESPONSE_FEEDBACK_KEY = "user_score";
export const SOURCE_CLICK_KEY = "user_click";
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@langchain/core": "^0.1.27",
"@langchain/langgraph-sdk": "^0.0.1-rc.7",
"@langchain/langgraph-sdk": "^0.0.1-rc.11",
"@types/dompurify": "^3.0.5",
"@types/lodash.orderby": "^4.6.9",
"@types/marked": "^5.0.1",
Expand Down
14 changes: 10 additions & 4 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,12 @@
zod "^3.22.4"
zod-to-json-schema "^3.22.3"

"@langchain/langgraph-sdk@^0.0.1-rc.7":
version "0.0.1-rc.7"
resolved "https://registry.yarnpkg.com/@langchain/langgraph-sdk/-/langgraph-sdk-0.0.1-rc.7.tgz#d1f5f23937a86219e298b8fa33b80b3d998a4177"
integrity sha512-d6wzMxvB0R40gs340aVS0a+o9DvcsQqtBoS4s6LGfZxlHB7CbLiflPEaM/3fKeEziLTxmYl2BWOfHsjwiMwOgQ==
"@langchain/langgraph-sdk@^0.0.1-rc.11":
version "0.0.1-rc.11"
resolved "https://registry.yarnpkg.com/@langchain/langgraph-sdk/-/langgraph-sdk-0.0.1-rc.11.tgz#60488ea8e3be89f6eae698b953e4092553cc112c"
integrity sha512-KddqkTxkzaPEoOm/4CklHkSyHCnHWDNotAtFJucGTpJ1ONgLaTtvkqhbdam7V/SUkoFVd1+8FHCskPhUH8nMlQ==
dependencies:
"@types/json-schema" "^7.0.15"
eventsource-parser "^1.1.2"
p-queue "^6.6.2"
p-retry "4"
Expand Down Expand Up @@ -1225,6 +1226,11 @@
dependencies:
"@types/trusted-types" "*"

"@types/json-schema@^7.0.15":
version "7.0.15"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==

"@types/json5@^0.0.29":
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
Expand Down
Loading

0 comments on commit d9c66b4

Please sign in to comment.