Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom graphs via langgraph-cli #333

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0df9527
WIP
nfcampos Apr 27, 2024
8901845
Update core
nfcampos May 3, 2024
8ebf545
cr
hwchase17 May 3, 2024
1b320a3
cr
hwchase17 May 3, 2024
398d6a8
cr
hwchase17 May 3, 2024
c592e41
Use published langgraph-sdk and langgraph-cli
nfcampos May 3, 2024
e6c17ea
Fix retrieval
nfcampos May 3, 2024
314369e
Get rag bot working
nfcampos May 3, 2024
435db45
Rename
nfcampos May 3, 2024
c0f49de
Fix
nfcampos May 3, 2024
53aeddd
Fix
nfcampos May 3, 2024
8ca9495
Fix interrupt on tools
nfcampos May 3, 2024
6fc91f4
Remove docker compose files
nfcampos May 7, 2024
68411e7
Fix connection string
nfcampos May 8, 2024
17d2c79
Add python version
nfcampos May 8, 2024
771212c
Fix missing url
nfcampos May 8, 2024
0fc76e1
Remove unused checkpointer
nfcampos May 8, 2024
da65904
Update
nfcampos May 8, 2024
8b3b236
Fix 500 when retrieving assistant created outside opengpts api
nfcampos May 8, 2024
01fdf96
Fix user qury
nfcampos May 9, 2024
2755495
Mark custom message types as loadable
nfcampos May 9, 2024
994ece6
Update sdk for better error messages
nfcampos May 9, 2024
40187ce
Fix serving ui from backend container
nfcampos May 9, 2024
2d99aed
Fix
nfcampos May 11, 2024
2dd2963
Update functionality of thumb up/down buttons in UI to update thread …
andrewnguonly May 16, 2024
8a5a9b0
fix frontend build error
nfcampos May 17, 2024
6fc7d6e
Improve deploy script
nfcampos May 17, 2024
5e73b01
Update deps
nfcampos May 17, 2024
6e2cfac
Make startup a little faster
nfcampos May 17, 2024
9f7294a
Fix streaming
nfcampos May 17, 2024
1b2e2a4
Bump
nfcampos May 17, 2024
6051a79
Update langgraph and langgraph-cli deps. (#343)
andrewnguonly May 21, 2024
f9a10b2
Update deploy version to 0.1.9. (#344)
andrewnguonly May 21, 2024
41c87b6
Update
nfcampos Jun 18, 2024
66a3065
Fix
nfcampos Jun 18, 2024
cef6f31
Fix tests
nfcampos Jun 18, 2024
1efb5dc
...
nfcampos Jun 18, 2024
13fbc08
ci
nfcampos Jun 18, 2024
130fa09
Fix
nfcampos Jun 18, 2024
aab77bb
Fix
nfcampos Jun 18, 2024
39d06af
Upgrade cli
nfcampos Jun 18, 2024
b421f6e
Add empty env file
nfcampos Jun 18, 2024
452dea2
Fix docker build
nfcampos Jun 18, 2024
ab0e09c
fix env
vbarda Jun 19, 2024
db4be93
Fix one
nfcampos Jun 19, 2024
c92fac4
Update
nfcampos Jun 19, 2024
1f1b33f
Fix
nfcampos Jun 19, 2024
f10976b
Add assert
nfcampos Jun 19, 2024
1fb5aff
Fix tests, better error messages
nfcampos Jun 19, 2024
3737979
fix rag
vbarda Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ POSTGRES_PORT=placeholder
POSTGRES_DB=placeholder
POSTGRES_USER=placeholder
POSTGRES_PASSWORD=placeholder
SCARF_NO_ANALYTICS=true
POSTGRES_HOST=postgres
SCARF_NO_ANALYTICS=true
64 changes: 23 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,16 @@ jobs:
secrets: inherit

test:
timeout-minutes: 5
timeout-minutes: 10
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKDIR }}
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
name: Python ${{ matrix.python-version }} tests
services:
# Label used to access the service container
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- "5432:5432"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
Expand All @@ -69,10 +51,10 @@ jobs:
- name: Install dependencies
run: |
poetry install --with test
- name: Install golang-migrate
- name: Start the service
run: |
wget -O golang-migrate.deb https://github.com/golang-migrate/migrate/releases/download/v4.17.0/migrate.linux-amd64.deb
sudo dpkg -i golang-migrate.deb && rm golang-migrate.deb
echo "OPENAI_API_KEY=placeholder" >> ../.env
poetry run langgraph up -c ../langgraph.json -d ../compose.override.yml --postgres-uri 'postgres://postgres:postgres@langgraph-postgres:5432/postgres?sslmode=disable' --verbose --wait
- name: Run tests
env:
POSTGRES_HOST: localhost
Expand All @@ -84,22 +66,22 @@ jobs:
run: make test

frontend-lint-and-build:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v3
- name: Setup Node.js (LTS)
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'yarn'
cache-dependency-path: frontend/yarn.lock
- name: Install frontend dependencies
run: yarn install
working-directory: ./frontend
- name: Run frontend lint
run: yarn lint
working-directory: ./frontend
- name: Build frontend
run: yarn build
working-directory: ./frontend
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v3
- name: Setup Node.js (LTS)
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "yarn"
cache-dependency-path: frontend/yarn.lock
- name: Install frontend dependencies
run: yarn install
working-directory: ./frontend
- name: Run frontend lint
run: yarn lint
working-directory: ./frontend
- name: Build frontend
run: yarn build
working-directory: ./frontend
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.env
.env.gcp.yaml
postgres-volume/
.langgraph-data
redis-volume/
backend/ui

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ COPY ./backend .

# Copy the frontend build
COPY --from=builder /frontend/dist ./ui
COPY --from=builder /frontend/dist/index.html ./ui/404.html

ENTRYPOINT [ "uvicorn", "app.server:app", "--host", "0.0.0.0", "--log-config", "log_config.json" ]
ENV PORT=8000

ENTRYPOINT uvicorn app.server:app --host 0.0.0.0 --port $PORT --log-config log_config.json
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: start

start:
cd backend && poetry run langgraph up -c ../langgraph.json -d ../compose.override.yml --postgres-uri 'postgres://postgres:postgres@langgraph-postgres:5432/postgres?sslmode=disable' --verbose
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.envrc
ui
.venv
.ruff_cache
25 changes: 4 additions & 21 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
# Backend Dockerfile
FROM python:3.11

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

# Install system dependencies
RUN apt-get update && rm -rf /var/lib/apt/lists/*
RUN wget -O golang-migrate.deb https://github.com/golang-migrate/migrate/releases/download/v4.17.0/migrate.${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.deb \
&& dpkg -i golang-migrate.deb \
&& rm golang-migrate.deb

# Install Poetry
RUN pip install poetry

# Set the working directory
WORKDIR /backend

# Copy only dependencies
COPY pyproject.toml poetry.lock* ./
# Copy the application
COPY . .

# Install all dependencies
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi

# Copy the rest of application code
COPY . .
RUN pip install -e .

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --start-interval=1s --retries=3 CMD [ "curl", "-f", "http://localhost:8000/health" ]
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --start-interval=1s --retries=3 CMD [ "curl", "-f", "http://localhost:8000/ok" ]

ENTRYPOINT [ "uvicorn", "app.server:app", "--host", "0.0.0.0", "--log-config", "log_config.json" ]
8 changes: 2 additions & 6 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ TEST_FILE ?= tests/unit_tests/
start:
poetry run uvicorn app.server:app --reload --port 8100 --log-config log_config.json

migrate:
migrate -database postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST):$(POSTGRES_PORT)/$(POSTGRES_DB)?sslmode=disable -path ./migrations up

test:
# We need to update handling of env variables for tests
YDC_API_KEY=placeholder OPENAI_API_KEY=placeholder poetry run pytest $(TEST_FILE)

YDC_API_KEY=placeholder OPENAI_API_KEY=placeholder LANGGRAPH_URL=http://localhost:8123 PGVECTOR_URI=postgresql+psycopg2://postgres:postgres@localhost:5433/postgres?sslmode=disable poetry run pytest $(TEST_FILE)

test_watch:
# We need to update handling of env variables for tests
YDC_API_KEY=placeholder OPENAI_API_KEY=placeholder poetry run ptw . -- $(TEST_FILE)
YDC_API_KEY=placeholder OPENAI_API_KEY=placeholder LANGGRAPH_URL=http://localhost:8123 PGVECTOR_URI=postgresql+psycopg2://postgres:postgres@localhost:5433/postgres?sslmode=disable poetry run ptw . -- $(TEST_FILE)

######################
# LINTING AND FORMATTING
Expand Down
Loading
Loading