Als Library nutzen
Der Classifier kann direkt als Library importiert werden — ohne REST-API, ohne laufenden Server. Ideal fuer:
- External Tasks in der ProcessCube Engine
- CLI-Tools und Skripte
- Eigene Anwendungen mit Ticket-Verarbeitung
Installation
npm install @processcube-io/knowledge-sdkDas Paket wird ueber den ProcessCube Marketplace verteilt. Siehe Installation fuer die Registry-Konfiguration.
Minimal-Beispiel
import { TicketClassifier } from '@processcube-io/knowledge-sdk/classifier/index';
const classifier = new TicketClassifier({
collections: [
{
name: 'engine',
repos: [{ org: '5minds', name: 'ProcessCube.Engine.MonoRepo', branch: 'main' }],
keywords: [
{ term: 'bpmn', weight: 2.0 },
{ term: 'timer', weight: 1.0 },
],
subThemes: [],
},
// ... weitere Collections
],
collectionDescriptions: {
engine: 'Workflow-Engine fuer BPMN-Prozesse',
},
});
const result = await classifier.classify({
correlationId: 'ticket-123',
title: 'Timer Event feuert nicht',
});
console.log(result.collection); // "engine"
console.log(result.confidence); // "high"Mit Feedback-Store
Fuer Self-Improvement braucht der Classifier einen SQLite Feedback-Store:
import { TicketClassifier } from '@processcube-io/knowledge-sdk/classifier/index';
import { FeedbackStore } from '@processcube-io/knowledge-sdk/classifier/feedback-store';
// Feedback-Store oeffnen (erstellt DB bei Bedarf)
const feedbackStore = new FeedbackStore('./feedback.sqlite');
const classifier = new TicketClassifier(config, null, feedbackStore);
// Klassifizieren (Ergebnis wird automatisch gespeichert)
const result = await classifier.classify({
correlationId: 'ticket-123',
title: 'Dashboard zeigt alte Daten',
});
// Feedback geben
feedbackStore.saveFeedback({
correlationId: 'ticket-123',
correctCollection: 'portal',
comment: 'War ein Portal-Problem, nicht LowCode',
});
// Naechste Klassifikation profitiert vom Feedback
const result2 = await classifier.classify({
correlationId: 'ticket-456',
title: 'Dashboard Widget laedt nicht',
});
// → "portal" (mit Feedback-Boost)Mit LLM (Slow Path)
const classifier = new TicketClassifier({
collections: COLLECTIONS,
collectionDescriptions: DESCRIPTIONS,
llm: {
provider: 'openai',
model: 'gpt-4o-mini',
apiKey: process.env.OPENAI_API_KEY,
temperature: 0,
maxTokens: 300,
},
fastPathThreshold: 0.8,
}, null, feedbackStore);In einem External Task
TypeScript
import { ExternalTaskWorker } from '@5minds/processcube_engine_client';
import { TicketClassifier } from '@processcube-io/knowledge-sdk/classifier/index';
import { FeedbackStore } from '@processcube-io/knowledge-sdk/classifier/feedback-store';
const feedbackStore = new FeedbackStore('./classifier-feedback.sqlite');
const classifier = new TicketClassifier(config, null, feedbackStore);
const worker = new ExternalTaskWorker('ClassifyTicket', async (task) => {
const { title, body, ticketId } = task.payload;
const result = await classifier.classify({
correlationId: ticketId,
title,
body,
});
return {
collection: result.collection,
subTheme: result.subTheme,
confidence: result.confidence,
repo: result.repo,
};
});
worker.start();Optionale Dependencies
| Dependency | Wofuer | Ohne |
|---|---|---|
better-sqlite3 | Feedback-Store | Kein Self-Improvement |
openai | LLM-Entscheider (Slow Path) | Nur Fast Path (regelbasiert) |
@tobilu/qmd | Such-Signale | Keine Suche, nur Keywords/Tags/Repo |