feat: implement knowledge extraction pipeline and centralized LLM client service
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user