Knowledge base
The knowledge base is a ChromaDB collection that the proxy queries on every request (when RAG is enabled). You can populate it by uploading individual files or by syncing entire GitHub and GitLab repositories.
Supported file types
Section titled “Supported file types”| Type | Extensions | Chunking |
|---|---|---|
| Docs | .txt, .md, .rst | Word-based sliding window |
| Code | .py, .js, .ts, .go, .rb, .java, .rs, .c, .cpp, .cs, .php, .swift, .kt, .scala, .sh | AST-aware (tree-sitter) — one chunk per top-level function/class |
Upload a file
Section titled “Upload a file”curl -X POST http://localhost:8000/internal/kb/upload \ -H "Authorization: Bearer $PROXY_MASTER_KEY" \ -F "file=@./runbook.md"Response:
{ "filename": "runbook.md", "chunks_ingested": 24}Re-uploading the same filename replaces the existing chunks (old ones are deleted first).
Sync a repository
Section titled “Sync a repository”Relay can index an entire GitHub or GitLab repository and keep it up to date incrementally.
# GitHubcurl -X POST http://localhost:8000/internal/kb/sync-repo \ -H "Authorization: Bearer $PROXY_MASTER_KEY" \ -H "Content-Type: application/json" \ -d '{"provider":"github","repo":"myorg/backend","token":"ghp_...","ref":"main"}'
# GitLabcurl -X POST http://localhost:8000/internal/kb/sync-repo \ -H "Authorization: Bearer $PROXY_MASTER_KEY" \ -H "Content-Type: application/json" \ -d '{"provider":"gitlab","repo":"123","token":"glpat-...","host":"https://gitlab.com"}'Returns immediately — sync runs in the background. Each sync:
- Fetches the HEAD commit SHA — skips everything if it matches the stored cursor
- On first run: indexes the full tree
- On subsequent runs: only changed, added, and removed files (via the compare API)
- Saves the cursor only when all files succeed — partial runs retry from the same point on the next call
To force a full re-index regardless of the stored cursor:
curl -X POST http://localhost:8000/internal/kb/sync-repo \ -H "Authorization: Bearer $PROXY_MASTER_KEY" \ -H "Content-Type: application/json" \ -d '{"provider":"github","repo":"myorg/backend","token":"ghp_...","force":true}'Auto-sync via config
Section titled “Auto-sync via config”Configure repositories to sync automatically on startup (or via CronJob):
code_review: sync_on_startup: true github: token: "ghp_..." include: - myorg/backend - myorg/frontend gitlab: token: "glpat-..." include: - "123"Kubernetes CronJob
Section titled “Kubernetes CronJob”syncJob: enabled: true schedule: "0 * * * *" # hourlySet code_review.sync_on_startup: false when using the CronJob to avoid double-syncing on pod restarts.
Debug retrieval
Section titled “Debug retrieval”Run a raw vector search to see distances and whether chunks pass the threshold. Useful for tuning score_threshold.
curl "http://localhost:8000/internal/kb/search?q=auth+middleware&n=5&repo=myorg/backend" \ -H "Authorization: Bearer $PROXY_MASTER_KEY"Response:
{ "query": "auth middleware", "threshold": 0.75, "results": [ { "distance": 0.61, "above_threshold": false, "source": "myorg/backend/middleware/auth.go", "symbol": "AuthMiddleware", "doc_type": "code", "text_preview": "func AuthMiddleware(next http.Handler) http.Handler {..." } ]}above_threshold: false means the chunk passes the filter and would be injected into context.
curl http://localhost:8000/internal/kb/stats \ -H "Authorization: Bearer $PROXY_MASTER_KEY"{ "total_documents": 4821 }Delete a source
Section titled “Delete a source”Remove all chunks for a specific file or repository path:
curl -X DELETE "http://localhost:8000/internal/kb/source?path=myorg/backend/middleware/auth.go" \ -H "Authorization: Bearer $PROXY_MASTER_KEY"Deletes the entire collection and recreates it empty (also clears all stored sync cursors):
curl -X DELETE http://localhost:8000/internal/kb/reset \ -H "Authorization: Bearer $PROXY_MASTER_KEY"Kubernetes seed job
Section titled “Kubernetes seed job”To pre-populate the knowledge base on first deploy with static docs:
apiVersion: batch/v1kind: Jobmetadata: name: kb-ingestspec: template: spec: restartPolicy: OnFailure containers: - name: ingest image: curlimages/curl:latest command: - sh - -c - | for f in /docs/*.md; do curl -sf -X POST http://relay:8000/internal/kb/upload \ -H "Authorization: Bearer $PROXY_MASTER_KEY" \ -F "file=@$f" done env: - name: PROXY_MASTER_KEY valueFrom: secretKeyRef: name: relay-master-key key: PROXY_MASTER_KEY volumeMounts: - name: docs mountPath: /docs volumes: - name: docs configMap: name: relay-docsFor repository indexing, use the sync CronJob instead — it handles incremental updates automatically.