Skip to content

Commit 28ef177

Browse files
committed
chore: cleanup after code review
- Remove dead d1.ts and vectorize.ts files - Remove stale D1 scripts from package.json - Remove unused getChunkIdsByDocument from neon.ts - Fix unsafe JSON.parse in query citation handler - Update brand.md stack references to PostgreSQL+pgvector - Add INGEST_SERVICE_URL to .env.example - Move sample questions to persistent strip above chat input
1 parent 06ac6dc commit 28ef177

14 files changed

Lines changed: 52 additions & 278 deletions

File tree

rag/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ DATABASE_URL=postgresql://...
55
OPENAI_API_KEY=sk-...
66
ANTHROPIC_API_KEY=sk-ant-...
77

8-
# Local dev URLs
8+
# Ingest service
9+
INGEST_SERVICE_URL=http://localhost:4000
910
API_URL=http://localhost:8787

rag/apps/api/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"scripts": {
66
"dev": "wrangler dev",
77
"deploy": "wrangler deploy",
8-
"db:create": "wrangler d1 create docrag",
9-
"db:migrate": "wrangler d1 execute docrag --file=schema.sql"
8+
"db:migrate": "psql $DATABASE_URL -f schema.sql"
109
},
1110
"dependencies": {
1211
"@anthropic-ai/sdk": "^0.30.0",

rag/apps/api/src/cf/d1.ts

Lines changed: 0 additions & 175 deletions
This file was deleted.

rag/apps/api/src/cf/neon.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,6 @@ export function createNeonClient(databaseUrl: string) {
130130
return Number(rows[0].count);
131131
},
132132

133-
async getChunkIdsByDocument(documentId: number): Promise<string[]> {
134-
const rows =
135-
await sql`SELECT id FROM chunks WHERE document_id = ${documentId}`;
136-
return rows.map((r: any) => r.id);
137-
},
138-
139133
async deleteDocument(id: number): Promise<void> {
140134
await sql`DELETE FROM documents WHERE id = ${id}`;
141135
},

rag/apps/api/src/cf/vectorize.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

rag/apps/api/src/worker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,11 @@ async function handleQuery(request: Request, env: Env): Promise<Response> {
320320
if (seen.has(targetId)) continue;
321321
const chunk = chunks.find((c) => c.targetId === targetId);
322322
if (!chunk) continue;
323-
const meta = chunk.metadata ? JSON.parse(chunk.metadata) : {};
323+
let meta: Record<string, unknown> = {};
324+
try {
325+
if (chunk.metadata) meta = JSON.parse(chunk.metadata);
326+
} catch {}
327+
324328
const citation = {
325329
index: citations.length + 1,
326330
blockId: chunk.blockId,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ WORKDIR /app
33

44
# Install deps (paths relative to repo root — Docker remote build uses repo root as context)
55
COPY rag/package.json rag/bun.lock* ./
6-
COPY rag/apps/ingest-service/package.json apps/ingest-service/
6+
COPY rag/apps/ingest/package.json apps/ingest/
77
COPY rag/packages/shared/package.json packages/shared/
88
RUN bun install --ignore-scripts
99

1010
# Copy source
1111
COPY rag/packages/shared/ packages/shared/
12-
COPY rag/apps/ingest-service/ apps/ingest-service/
12+
COPY rag/apps/ingest/ apps/ingest/
1313
COPY rag/tsconfig.json .
1414

1515
# Production stage
1616
FROM oven/bun:1-slim
1717
WORKDIR /app
1818

1919
COPY rag/package.json rag/bun.lock* ./
20-
COPY rag/apps/ingest-service/package.json apps/ingest-service/
20+
COPY rag/apps/ingest/package.json apps/ingest/
2121
COPY rag/packages/shared/package.json packages/shared/
2222
RUN bun install --ignore-scripts
2323

2424
COPY --from=build /app/packages/shared packages/shared
25-
COPY --from=build /app/apps/ingest-service apps/ingest-service
25+
COPY --from=build /app/apps/ingest apps/ingest
2626
COPY rag/tsconfig.json .
2727

2828
EXPOSE 4000
2929
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
3030
CMD bun -e "fetch('http://localhost:4000/health').then(r=>{if(!r.ok)process.exit(1)})"
3131

32-
CMD ["bun", "run", "apps/ingest-service/index.ts"]
32+
CMD ["bun", "run", "apps/ingest/index.ts"]

rag/apps/ingest-service/docker-compose.yml renamed to rag/apps/ingest/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
ingest:
33
build:
44
context: ../../..
5-
dockerfile: rag/apps/ingest-service/Dockerfile
5+
dockerfile: rag/apps/ingest/Dockerfile
66
ports:
77
- "4000:4000"
88
environment:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@docrag/ingest-service",
2+
"name": "@docrag/ingest",
33
"private": true,
44
"type": "module",
55
"scripts": {

0 commit comments

Comments
 (0)