feat: add learning_relevance field to topics and implement KnowledgeGraph UI with handbook synchronization capabilities
This commit is contained in:
30
pb_migrations/1780000001_updated_topics.js
Normal file
30
pb_migrations/1780000001_updated_topics.js
Normal 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)
|
||||||
|
})
|
||||||
@@ -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.
|
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.`;
|
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:
|
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:
|
Analyze this graph and return ONLY the optimized JSON object with this EXACT structure:
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export async function saveTopics(topics) {
|
|||||||
label: t.label,
|
label: t.label,
|
||||||
type: t.type,
|
type: t.type,
|
||||||
description: t.description,
|
description: t.description,
|
||||||
|
learning_relevance: t.learning_relevance || 'standard',
|
||||||
}, { requestKey: null })));
|
}, { requestKey: null })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user