Skip to content

Commit

Permalink
feat: migrate to weaviate (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
anbraten authored Apr 17, 2024
1 parent 7d31761 commit b4a033c
Show file tree
Hide file tree
Showing 13 changed files with 237 additions and 127 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
!/.npmrc
!/tsconfig.json
!/requirements.txt
!/.nuxt

# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
Expand Down
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build

FROM python:3.11-slim
FROM alpine:3.14 as weaviate
ARG WEAVIATE_VERSION=1.24.8
WORKDIR /app
RUN wget https://github.com/weaviate/weaviate/releases/download/v${WEAVIATE_VERSION}/weaviate-v${WEAVIATE_VERSION}-linux-amd64.tar.gz && \
tar -xzf weaviate-v${WEAVIATE_VERSION}-linux-amd64.tar.gz

FROM node:20-alpine
ENV NUXT_DATA_PATH=/app/data
ENV NUXT_MIGRATIONS_PATH=/app/migrations
ENV NODE_ENV=production
ENV NITRO_PORT=3000
EXPOSE 3000
WORKDIR /app
RUN apt update -y && apt install curl git musl-dev -y && \
ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 && \
curl -sL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
pip install chromadb
RUN apk update && apk add git musl-dev
COPY --from=weaviate /app/weaviate /bin/weaviate
COPY docker/start.sh .
COPY server/db/migrations /app/migrations
COPY --from=builder /app/.output .output
Expand Down
26 changes: 20 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
version: '3.4'

services:
chroma:
image: chromadb/chroma
weaviate:
command:
- --host
- 0.0.0.0
- --port
- '8080'
- --scheme
- http
image: cr.weaviate.io/semitechnologies/weaviate:1.24.8
ports:
- 8000:8000
volumes:
- chroma_data:/var/lib/weaviate
- 8080:8080
restart: on-failure:0
volumes:
- weaviate_data:/var/lib/weaviate
environment:
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
DEFAULT_VECTORIZER_MODULE: 'none'
ENABLE_MODULES: ''
CLUSTER_HOSTNAME: 'node1'

volumes:
chroma_data:
weaviate_data:
11 changes: 9 additions & 2 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/bash
#!/bin/sh

set -m # to make job control work
node .output/server/index.mjs --port 3000 --host 0.0.0.0 &
chroma run --path /app/data/chroma --port 8000 --host 0.0.0.0 &

export PERSISTENCE_DATA_PATH=/app/vectorstore
export QUERY_DEFAULTS_LIMIT=25
export AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED='true'
export ENABLE_MODULES=''
export DEFAULT_VECTORIZER_MODULE='none'
export CLUSTER_HOSTNAME='node1'
weaviate --port 8000 --host 0.0.0.0 --scheme http &
fg %1 # gross!
1 change: 0 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default defineNuxtConfig({
telemetry: true,
runtimeConfig: {
ai: {
vectorDatabaseUrl: 'http://localhost:8000',
token: '',
},
auth: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@gitbeaker/rest": "^40.0.1",
"@langchain/community": "^0.0.41",
"@langchain/openai": "^0.0.23",
"@langchain/weaviate": "^0.0.1",
"better-sqlite3": "^9.4.3",
"chromadb": "^1.8.1",
"consola": "^3.2.3",
"drizzle-orm": "^0.30.4",
"glob": "^10.3.10",
Expand Down
124 changes: 80 additions & 44 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions server/api/forges/[forge_id]/index.delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forgeSchema, userForgesSchema } from '~/server/schemas';
import { forgeSchema, repoSchema, userForgesSchema } from '~/server/schemas';
import { eq, and } from 'drizzle-orm';

export default defineEventHandler(async (event) => {
Expand All @@ -15,11 +15,16 @@ export default defineEventHandler(async (event) => {

await db.delete(userForgesSchema).where(eq(userForgesSchema.forgeId, forgeId)).run();

const forge = await db
await db
.delete(forgeSchema)
.where(and(eq(forgeSchema.owner, user.id), eq(forgeSchema.id, forgeId)))
.returning()
.get();

return forge;
const repos = await db.select().from(repoSchema).where(eq(repoSchema.forgeId, forgeId)).all();
for await (const repo of repos) {
await deleteRepo(repo.id);
}

return 'ok';
});
Loading

0 comments on commit b4a033c

Please sign in to comment.