feat: implement knowledge extraction pipeline and centralized LLM client service
All checks were successful
On Push to Main / test (push) Successful in 31s
On Push to Main / publish (push) Successful in 59s
On Push to Main / deploy-dev (push) Successful in 1m32s

This commit is contained in:
RaymondVerhoef
2026-05-24 22:38:46 +02:00
parent e9f37056b6
commit b07c4808a6
3 changed files with 193 additions and 5 deletions

View File

@@ -24,10 +24,8 @@ const EXTRACTION_SYSTEM_PROMPT = `You are an AI knowledge extractor for Respelli
You receive a source text. Extract every distinct concept, role, and process from it and emit them through the emit_knowledge_graph tool.
CRITICAL INSTRUCTIONS FOR COMPLETENESS:
- Extract EVERY SINGLE distinct role, process, and concept described or mentioned in the source text.
- DO NOT summarise, skip, truncate, or omit any items.
- If the document contains 29 roles, the topics array must contain exactly 29 role topics.
- Completeness is paramount. Failing to extract all topics loses critical company knowledge.
- Extract up to 15 of the most important distinct roles, processes, and concepts described or mentioned in the source text.
- Do not exceed 15 topics per chunk to prevent the response from being truncated.
- Facts should be integrated into the descriptions of other topics — never extracted as standalone topics.
- Keep descriptions concise (max 3 sentences) so the response fits.

View File

@@ -348,8 +348,12 @@ export async function callLLM(options) {
result = await withRetry(
async () => {
if (limiter) await limiter.acquire({ signal });
let didTimeout = false;
const timeoutCtl = new AbortController();
const timer = setTimeout(() => timeoutCtl.abort(new DOMException('Timeout', 'TimeoutError')), timeoutMs);
const timer = setTimeout(() => {
didTimeout = true;
timeoutCtl.abort();
}, timeoutMs);
const fetchSignal = linkSignals(signal, timeoutCtl.signal);
try {
@@ -381,6 +385,11 @@ export async function callLLM(options) {
}
return await response.json();
} catch (err) {
if (didTimeout) {
throw new Error('Timeout');
}
throw err;
} finally {
if (timer) clearTimeout(timer);
}