feat: Phase 3 — RAG-Anbindung fuer alle 18 Dokumenttypen + Vendor Contract Review
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 34s
CI / test-python-backend-compliance (push) Successful in 26s
CI / test-python-document-crawler (push) Successful in 21s
CI / test-python-dsms-gateway (push) Successful in 17s
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 34s
CI / test-python-backend-compliance (push) Successful in 26s
CI / test-python-document-crawler (push) Successful in 21s
CI / test-python-dsms-gateway (push) Successful in 17s
Migrate queryRAG from klausur-service GET to bp-core-rag-service POST with multi-collection support. Each of the 18 ScopeDocumentType now gets a type-specific RAG collection and optimized search query instead of the generic fallback. Vendor-compliance contract review now uses LLM + RAG for real analysis with mock fallback on error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,24 +1,35 @@
|
||||
/**
|
||||
* Shared RAG query utility for the Drafting Engine.
|
||||
*
|
||||
* Queries the DSFA RAG corpus via klausur-service for relevant legal context.
|
||||
* Queries the bp-core-rag-service for relevant legal context.
|
||||
* Supports multi-collection search via POST /api/v1/search.
|
||||
* Used by both chat and draft routes.
|
||||
*/
|
||||
|
||||
const KLAUSUR_SERVICE_URL = process.env.KLAUSUR_SERVICE_URL || 'http://klausur-service:8086'
|
||||
const RAG_SERVICE_URL = process.env.RAG_SERVICE_URL || 'http://bp-core-rag-service:8097'
|
||||
|
||||
/**
|
||||
* Query the RAG corpus for relevant legal documents.
|
||||
*
|
||||
* @param query - The search query (e.g. "DSFA Art. 35 DSGVO")
|
||||
* @param query - The search query (e.g. "Art. 35 DSGVO Risikobewertung")
|
||||
* @param topK - Number of results to return (default: 3)
|
||||
* @param collection - Optional RAG collection name (e.g. "bp_dsfa_corpus")
|
||||
* @returns Formatted string of legal context, or empty string on error
|
||||
*/
|
||||
export async function queryRAG(query: string, topK = 3): Promise<string> {
|
||||
export async function queryRAG(query: string, topK = 3, collection?: string): Promise<string> {
|
||||
try {
|
||||
const url = `${KLAUSUR_SERVICE_URL}/api/v1/dsfa-rag/search?query=${encodeURIComponent(query)}&top_k=${topK}`
|
||||
const res = await fetch(url, {
|
||||
const body: Record<string, unknown> = {
|
||||
query,
|
||||
top_k: topK,
|
||||
}
|
||||
if (collection) {
|
||||
body.collection = collection
|
||||
}
|
||||
|
||||
const res = await fetch(`${RAG_SERVICE_URL}/api/v1/search`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
signal: AbortSignal.timeout(10000),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user