feat: add learning_relevance field to topics and implement KnowledgeGraph UI with handbook synchronization capabilities
All checks were successful
On Push to Main / test (push) Successful in 30s
On Push to Main / publish (push) Successful in 58s
On Push to Main / deploy-dev (push) Successful in 1m39s

This commit is contained in:
RaymondVerhoef
2026-05-19 08:40:52 +02:00
parent fa5dcaeb01
commit d23b0b6b16
3 changed files with 41 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_2800040823")
// add field
collection.fields.addAt(4, new Field({
"autogeneratePattern": "",
"help": "",
"hidden": false,
"id": "text_learning_relevance",
"max": 0,
"min": 0,
"name": "learning_relevance",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
}))
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2800040823")
// remove field
collection.fields.removeById("text_learning_relevance")
return app.save(collection)
})

View File

@@ -299,8 +299,17 @@ Rules:
3. Identify missing logical relations (depends_on, part_of, related_to) if two topics are conceptually linked but missing a relation.
4. Return ONLY a valid JSON object describing the ACTIONS to take. Do not return the entire graph. Do not wrap in markdown blocks.`;
// Send a compact representation to minimize token usage and avoid rate limits.
// The AI only needs id, label, and type to identify duplicates/merges.
const compactTopics = currentTopics.map(({ id, label, type }) => ({ id, label, type }));
const compactRelations = currentRelations.map(r => ({
source: r.source?.id || r.source,
target: r.target?.id || r.target,
type: r.type
}));
const userPrompt = `Here is the current knowledge graph:
${JSON.stringify({ topics: currentTopics, relations: currentRelations }, null, 2)}
${JSON.stringify({ topics: compactTopics, relations: compactRelations })}
Analyze this graph and return ONLY the optimized JSON object with this EXACT structure:
{

View File

@@ -14,6 +14,7 @@ export async function saveTopics(topics) {
label: t.label,
type: t.type,
description: t.description,
learning_relevance: t.learning_relevance || 'standard',
}, { requestKey: null })));
}