feat: implement core knowledge graph UI components, extraction pipeline, and initial platform navigation pages

This commit is contained in:
RaymondVerhoef
2026-05-10 21:33:02 +02:00
parent a626042092
commit 31aacd68d5
14 changed files with 1634 additions and 480 deletions

View File

@@ -1,28 +1,28 @@
import { anthropicApi } from './api';
import { storage } from './storage';
const SYSTEM_PROMPT = `Je bent een AI-kennisextractor voor Respellion, een IT-bedrijf gericht op "radicale transparantie".
Je krijgt een brontekst. Jouw taak is om kernconcepten, rollen, processen en feiten te extraheren en deze als een gestructureerde JSON Kennisgraaf terug te geven.
const SYSTEM_PROMPT = `You are an AI knowledge extractor for Respellion, an IT company built on radical transparency.
You receive a source text. Your task is to extract core concepts, roles, processes, and facts, and return them as a structured JSON Knowledge Graph.
Geef ALTIJD een valide JSON object terug in het volgende formaat:
ALWAYS return a valid JSON object in the following format:
{
"topics": [
{
"id": "unieke-slug",
"label": "Titel van onderwerp",
"id": "unique-slug",
"label": "Topic title",
"type": "concept | role | process | fact",
"description": "Een beknopte, heldere uitleg van max 3 zinnen."
"description": "A concise, clear explanation of max 3 sentences."
}
],
"relations": [
{
"source": "id-van-topic-1",
"target": "id-van-topic-2",
"source": "topic-id-1",
"target": "topic-id-2",
"type": "related_to | depends_on | part_of | executed_by"
}
]
}
Zorg dat je alleen JSON teruggeeft, geen markdown blokken of andere tekst.`;
Return JSON only. No markdown blocks or other text.`;
/**
* Voert tekst door de Anthropic API en slaat de resulterende topics op.
@@ -44,7 +44,7 @@ export async function processSourceText(textContent, sourceName) {
try {
// 2. Roep Anthropic API aan
const responseText = await anthropicApi.generateContent(SYSTEM_PROMPT, `Analyseer de volgende tekst:\n\n${textContent}`);
const responseText = await anthropicApi.generateContent(SYSTEM_PROMPT, `Analyze the following text:\n\n${textContent}`);
// 3. Parse JSON (veilig)
let extractedData;
@@ -54,7 +54,7 @@ export async function processSourceText(textContent, sourceName) {
const jsonStr = jsonMatch ? jsonMatch[0] : responseText;
extractedData = JSON.parse(jsonStr);
} catch (e) {
throw new Error('AI response was geen geldige JSON.');
throw new Error('AI response was not valid JSON.');
}
// 4. Deduplicatie en opslag van Topics en Relaties