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

feat: Add support for langchain-anthropic in LLMEndpoint completes CORE-144 #2991

Open
wants to merge 103 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
6f205a4
add: auth dropbox
chloedia Jul 15, 2024
483db0a
fix: dropbox sync creds
chloedia Jul 15, 2024
c587456
add: list dropbox items
chloedia Jul 15, 2024
1d9070f
add: weblink
chloedia Jul 16, 2024
d55f411
feat: poetry lock
StanGirard Jul 16, 2024
9d98792
feat: Add Dropbox sync functionality
StanGirard Jul 16, 2024
78d161f
fix: DropBox integration link & front dropbox
chloedia Jul 16, 2024
ac0d211
add: notification to DropBox
chloedia Jul 16, 2024
36a4ecd
fix: delete Session middleware
chloedia Jul 17, 2024
98c216a
fix: refacto syncs
chloedia Jul 17, 2024
6631975
fix: remove useless debug & fix dropbox refresh
chloedia Jul 17, 2024
3b00e66
fix: merge problems
chloedia Jul 17, 2024
7625182
feat: Update sync datetime formats for Google Drive and Azure Drive &…
chloedia Jul 18, 2024
806af03
add: retry fetch_files Azure
chloedia Jul 18, 2024
f002a09
add : notion auth
chloedia Jul 18, 2024
e1c2742
feat: Add Notion sync functionality and update dependencies
chloedia Jul 18, 2024
1a7a961
add: download file for notion
chloedia Jul 19, 2024
e02d273
add: notion front
chloedia Jul 19, 2024
c90f08b
fix: add notion icon url
chloedia Jul 19, 2024
6e76108
add: is_subfolder, fix: notif failures,
chloedia Jul 22, 2024
36ae406
add: icon
chloedia Jul 22, 2024
8f07c79
add: front show emoji
chloedia Jul 22, 2024
8d18ba9
add: add async to notion integration
chloedia Jul 23, 2024
df73259
feat: Add Notion sync functionality and update dependencies
chloedia Jul 23, 2024
86a4721
add: redis
chloedia Jul 23, 2024
693d9c3
add: store in db + get_files from db
chloedia Jul 26, 2024
4e8b8f0
add: migration notion sync
chloedia Jul 30, 2024
4fa4f6e
tests sync notion
AmineDiro Jul 30, 2024
3443586
fix test notion session sync
AmineDiro Jul 30, 2024
9971d2b
fix test sync
AmineDiro Jul 30, 2024
24672c0
moved parsed to worker and update packages
AmineDiro Jul 31, 2024
8819379
add: get_file, upload, add notion page to db
chloedia Jul 31, 2024
8ca9e53
add: get_file, upload, add notion page to db
chloedia Jul 31, 2024
5b50f80
add: get_file, upload, add notion page to db
chloedia Jul 31, 2024
794e3ad
fix: merge with main
chloedia Jul 31, 2024
95bf927
fix: merge with main
chloedia Jul 31, 2024
c0a7fec
fix: merge with main
chloedia Jul 31, 2024
03fa348
feat: add sync logic
chloedia Jul 31, 2024
13709b6
init quivr_worker
AmineDiro Aug 1, 2024
0d3b698
Merge remote-tracking branch 'origin/main' into feat/separate-celery-…
AmineDiro Aug 1, 2024
837f33d
moved parsers
AmineDiro Aug 1, 2024
bd8763f
merged main
AmineDiro Aug 1, 2024
a4150f1
refacto file
AmineDiro Aug 1, 2024
de8ae64
add: sync in sync cron job
chloedia Aug 1, 2024
0584a79
moved pdf parsing to megaparse
Aug 2, 2024
5a9d27a
moved md5 in core to sha1
Aug 2, 2024
cd01abc
moved check_premium + changed qfile to sha1
Aug 2, 2024
e775644
finish: regular notion sync
chloedia Aug 2, 2024
9a93dbb
finish: regular notion sync
chloedia Aug 2, 2024
1397d49
quivr_core qfile changes
AmineDiro Aug 2, 2024
67bf3a0
refacto processing + tasks
AmineDiro Aug 2, 2024
b1d5f45
parse simple tests
Aug 2, 2024
207e4f5
added llama-parse dep
Aug 2, 2024
071670b
added processing audio to parsers + tests
Aug 3, 2024
e8b7423
crawler celery workers
Aug 3, 2024
5a38a98
dockerfile.dev workers
Aug 3, 2024
7a463f5
dockerfile.dev workers
Aug 4, 2024
e918c73
Merge branch 'main' into feat/notion-oauth-sync
chloedia Aug 4, 2024
3c2cae2
fix: double mime type in file name
chloedia Aug 4, 2024
94f7948
working docker-compose
AmineDiro Aug 4, 2024
dbd2191
patch json dump tests
AmineDiro Aug 4, 2024
99491e7
logger + placeholder test
AmineDiro Aug 4, 2024
499b907
Delete backend/supabase/migrations/20240107152745_ollama.sql
AmineDiro Aug 4, 2024
6c29231
add: normalize async for BaseSync & SyncUtils
chloedia Aug 4, 2024
1a27e23
remove prints
chloedia Aug 4, 2024
e8ac203
changed dockerfile
AmineDiro Aug 5, 2024
64207c4
default venv
AmineDiro Aug 5, 2024
52b5037
fix original file_name
AmineDiro Aug 5, 2024
5144275
skip all known processors checks
AmineDiro Aug 5, 2024
12c2d92
rolled back crawler
AmineDiro Aug 5, 2024
61d9b47
production docker images
AmineDiro Aug 5, 2024
c129cd0
ignore tox env
AmineDiro Aug 5, 2024
71733e4
rolled back crawler
AmineDiro Aug 5, 2024
803f425
fix: sync update only modified files
chloedia Aug 5, 2024
704b47d
merge with main
chloedia Aug 5, 2024
3f4f323
sync utils rewrite
AmineDiro Aug 6, 2024
0463c8a
push new lock
chloedia Aug 6, 2024
4016da9
push new lock
chloedia Aug 6, 2024
adc71b7
push new lock
chloedia Aug 6, 2024
32d3b57
remove duplicate NotionService
chloedia Aug 6, 2024
46df016
Merged feat/notion-oauth
AmineDiro Aug 6, 2024
dafda78
lock files ok
AmineDiro Aug 6, 2024
995420c
feat: separate celery workers (#2948)
AmineDiro Aug 6, 2024
e5aba1a
updated router
AmineDiro Aug 6, 2024
4fada64
merge frontend main
AmineDiro Aug 7, 2024
7f71a6b
fix notion
AmineDiro Aug 7, 2024
86cc06b
remerged notion and main
AmineDiro Aug 7, 2024
fd47ed7
fixed notion error front
AmineDiro Aug 7, 2024
4517af8
Merge remote-tracking branch 'origin/release/quivr-core-0.1' into fea…
AmineDiro Aug 7, 2024
5012df4
Merge pull request #2965 from QuivrHQ/feat/separate-celery-workers
chloedia Aug 7, 2024
95e184f
Feat/fix tests (#2971)
StanGirard Aug 7, 2024
9b3178b
Merge branch 'main' into release/quivr-core-0.1
StanGirard Aug 8, 2024
b3ea3c2
feat: 🎸 utils
StanGirard Aug 8, 2024
053ce71
feat(models): add more tests on service (#2977)
StanGirard Aug 8, 2024
d19d01e
feat(tests): improve bash script with select (#2978)
StanGirard Aug 8, 2024
f1407cc
feat: Add support for langchain-anthropic in LLMEndpoint
StanGirard Aug 12, 2024
8337af3
fix: Knowledge (#2966)
chloedia Aug 12, 2024
f832940
fix: syncs workers + notifier (#2996)
AmineDiro Aug 14, 2024
e9d0977
Merge branch 'release/quivr-core-0.1' into feat/anthropic-added
StanGirard Aug 20, 2024
3f4c256
feat: add knowledge_brain (#2988)
chloedia Aug 20, 2024
ea0c240
feat(rye): changed package manager (#3019)
StanGirard Aug 21, 2024
ec8b432
Merge branch 'release/quivr-core-0.1' into feat/anthropic-added
StanGirard Aug 21, 2024
147625f
feat: Add langchain-anthropic dependency
StanGirard Aug 21, 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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ CELERY_BROKER_URL=redis://redis:6379/0
CELEBRY_BROKER_QUEUE_NAME=quivr-preview.fifo
QUIVR_DOMAIN=http://localhost:3000/
BACKEND_URL=http://localhost:5050
EMBEDDING_DIM=1536
#COHERE_API_KEY=CHANGE_ME

#RESEND
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/backend-core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@ jobs:
- 9998:9998

steps:
- name: Checkout code
- name: 👀 Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
- name: 🔨 Install the latest version of rye
uses: eifinger/setup-rye@v4
with:
python-version: "3.11"

- name: Install dependencies
enable-cache: true
working-directory: backend
- name: 🔄 Sync dependencies
run: |
cd backend/core
python -m pip install --upgrade pip
pip install poetry
poetry install -E base --with dev,test
cd backend
UV_INDEX_STRATEGY=unsafe-first-match rye sync --no-lock

- name: Run tests
env:
Expand All @@ -42,6 +40,5 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y libmagic-dev poppler-utils libreoffice tesseract-ocr pandoc
tesseract --version
cd backend/core
poetry run tox
rye test
130 changes: 60 additions & 70 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,64 @@
# name: Backend Tests
name: Run Tests API and Worker

# on:
# push:
# branches: [main]
# paths:
# - 'backend/**'
# pull_request:
# branches: [main]
# paths:
# - 'backend/**'
# workflow_dispatch:
# inputs:
# logLevel:
# description: 'Log level'
# required: true
# default: 'warning'
# type: choice
# options:
# - info
# - warning
# - debug
# tags:
# description: 'Test scenario tags'
# required: false
# type: boolean
# environment:
# description: 'Environment to run tests against'
# type: environment
# required: false
on:
pull_request:
paths:
- "backend/**"
workflow_dispatch:

# jobs:
# build:
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: ./backend
# environment: preview
# strategy:
# matrix:
# python-version: ["3.11"]
jobs:
test:
runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
# with:
# python-version: ${{ matrix.python-version }}
# cache: "pip"
# - name: Install system dependencies
# run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install pytest pytest-emoji pytest-md pytest-mock
# pip install pyright
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Run pytest
# uses: pavelzw/pytest-action@510c5e90c360a185039bea56ce8b3e7e51a16507 # v2
# with:
# verbose: true
# emoji: true
# job-summary: true
# click-to-expand: false
# report-title: 'Test Report'
# env:
# SUPABASE_URL: ${{secrets.SUPABASE_URL}}
# SUPABASE_SERVICE_KEY: ${{secrets.SUPABASE_SERVICE_KEY}}
# OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}}
# ANTHROPIC_API_KEY: ${{secrets.ANTHROPIC_API_KEY}}
# JWT_SECRET_KEY: ${{secrets.JWT_SECRET_KEY}}
# CI_TEST_API_KEY: ${{secrets.CI_TEST_API_KEY}}
# CELERY_BROKER_URL: ${{secrets.CELERY_BROKER_URL}}
steps:
- name: 👀 Checkout code
uses: actions/checkout@v2

- name: 🔨 Install the latest version of rye
uses: eifinger/setup-rye@v4
with:
enable-cache: true
working-directory: backend

- name: 🔄 Sync dependencies
run: |
cd backend
UV_INDEX_STRATEGY=unsafe-first-match rye sync --no-lock


- name: 🚤 Install Supabase CLI
run: |
ARCHITECTURE=$(uname -m)
if [ "$ARCHITECTURE" = "x86_64" ]; then
wget https://github.com/supabase/cli/releases/download/v1.163.6/supabase_1.163.6_linux_amd64.deb
sudo dpkg -i supabase_1.163.6_linux_amd64.deb
elif [ "$ARCHITECTURE" = "aarch64" ]; then
wget https://github.com/supabase/cli/releases/download/v1.163.6/supabase_1.163.6_linux_arm64.deb
sudo dpkg -i supabase_1.163.6_linux_arm64.deb
fi

- name: 😭 Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libmagic-dev poppler-utils libreoffice tesseract-ocr pandoc

- name: Install dependencies and run tests
env:
OPENAI_API_KEY: this-is-a-fake-openai-api-key
SUPABASE_URL: http://localhost:54321
SUPABASE_SERVICE_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
PG_DATABASE_URL: postgresql://postgres:postgres@localhost:54322/postgres
PG_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost:54322/postgres
ANTHROPIC_API_KEY: null
JWT_SECRET_KEY: super-secret-jwt-token-with-at-least-32-characters-long
AUTHENTICATE: true
TELEMETRY_ENABLED: true
CELERY_BROKER_URL: redis://redis:6379/0
CELEBRY_BROKER_QUEUE_NAME: quivr-preview.fifo
QUIVR_DOMAIN: http://localhost:3000/
BACKEND_URL: http://localhost:5050
EMBEDDING_DIM: 1536
run: |
cd backend
supabase db start
rye test -p quivr-api -p quivr-worker
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ backend/.python-version
**/.pnp
.pnp.js

Pipfile

# testing
**/coverage

Expand Down Expand Up @@ -59,7 +61,7 @@ backend/core/local_models/*

## scripts
package-lock.json
backend/celerybeat-schedule
celerybeat-schedule
frontend/public/robots.txt
frontend/public/sitemap*

Expand Down Expand Up @@ -98,3 +100,4 @@ backend/core/examples/chatbot/.chainlit/translations/en-US.json

# Tox
.tox
Pipfile
105 changes: 105 additions & 0 deletions .run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash
set -e

## TESTS SUITES
test_suites=(
"Backend Core:cd backend/core && tox -p auto"
"Worker:cd backend && pytest worker"
"API:cd backend && pytest api"
)

# Check if gum is installed
if ! command -v gum &>/dev/null; then
echo "gum is not installed. Please install it with 'brew install gum'."
exit 1
fi

root_dir=$(pwd)

# Function to check if Tika server is running
check_tika_server() {
if nc -z localhost 9998 >/dev/null 2>&1; then
return 0
else
gum style --foreground 196 "Error: Tika server is not running on port 9998."
gum style --foreground 226 "Please start the Tika server before running the tests."
gum style --foreground 226 "Run 'docker run -d -p 9998:9998 apache/tika' to start the Tika server."
return 1
fi
}

# select test suites to run, either all or one of the following
get_test_suites_to_run() {
gum style --bold "Select test suites to run:"
options=("All" "${test_suites[@]%%:*}")
selected=$(gum choose "${options[@]}")
if [[ "$selected" == "All" ]]; then
gum style --bold "Running all test suites"
else
# Find the matching test suite
for suite in "${test_suites[@]}"; do
if [[ "${suite%%:*}" == "$selected" ]]; then
test_suites=("$suite")
break
fi
done
fi
}

# Function to run a single test suite
run_test_suite() {
local suite_name=$1
local command=$2
local exit_code

gum style --border normal --border-foreground 99 --padding "1 2" --bold "$suite_name Tests"
eval "$command"
exit_code=$?
cd "$root_dir"

if [ $exit_code -eq 0 ]; then
gum style --foreground 46 "$suite_name Tests: PASSED"
else
gum style --foreground 196 "$suite_name Tests: FAILED"
fi

return $exit_code
}

run_tests() {
get_test_suites_to_run
# gum spin --spinner dot --title "Running tests..." -- sleep 1

local all_passed=true
local results=()

for suite in "${test_suites[@]}"; do
IFS=':' read -r suite_name suite_command <<< "$suite"
if ! run_test_suite "$suite_name" "$suite_command"; then
all_passed=false
fi
results+=("$suite_name:$?")
done

# Print summary of test results
gum style --border double --border-foreground 99 --padding "1 2" --bold "Test Summary"
for result in "${results[@]}"; do
IFS=':' read -r suite_name exit_code <<< "$result"
if [ "$exit_code" -eq 0 ]; then
gum style --foreground 46 "✓ $suite_name: PASSED"
else
gum style --foreground 196 "✗ $suite_name: FAILED"
fi
done

# Return overall exit code
$all_passed
}

# Main execution
if check_tika_server; then
run_tests
exit $?
else
exit 1
fi
50 changes: 23 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
test:
pytest backend/

dev-build:
DOCKER_BUILDKIT=1 docker compose -f docker-compose.dev.yml build backend-core
DOCKER_BUILDKIT=1 docker compose -f docker-compose.dev.yml up --build

dev:
DOCKER_BUILDKIT=1 docker compose -f docker-compose.dev.yml up
.DEFAULT_TARGET=help

## help: Display list of commands
.PHONY: help
help:
@echo "Available commands:"
@sed -n 's|^##||p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's|^| |'

dev-saas:
docker compose -f docker-compose-dev-saas-supabase.yml build backend-core
docker compose -f docker-compose-dev-saas-supabase.yml up --build

dev-saas-back:
docker compose -f docker-compose-dev-only-back-saas-supabase.yml build backend-core
docker compose -f docker-compose-dev-only-back-saas-supabase.yml up --build backend-core
## dev: Start development environment
.PHONY: dev
dev:
DOCKER_BUILDKIT=1 docker compose -f docker-compose.dev.yml up --build

dev-stan:
docker compose -f docker-compose-no-frontend.dev.yml up --build
dev-build:
DOCKER_BUILDKIT=1 docker compose -f docker-compose.dev.yml build --no-cache
DOCKER_BUILDKIT=1 docker compose -f docker-compose.dev.yml up

## prod: Build and start production environment
.PHONY: prod
prod:
docker compose build backend-core
docker compose -f docker-compose.yml up --build

test-type:
@if command -v python3 &>/dev/null; then \
python3 -m pyright; \
else \
python -m pyright; \
fi

## front: Build and start frontend
.PHONY: front
front:
cd frontend && yarn build && yarn start
cd frontend && yarn && yarn build && yarn start

## test: Run tests
.PHONY: test
test:
cd backend/core && ./scripts/run_tests.sh
# Ensure dependencies are installed with dev and test extras
# poetry install --with dev,test && brew install tesseract pandoc libmagic
./.run_tests.sh
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.11"
2 changes: 2 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
**/.docusaurus/
**/node_modules/
**/.venv/
**/.tox/
**/.tox-docker/
Loading
Loading