@plust/datasleuth
Version:
Build LLM-powered research pipelines and output structured data.
92 lines (91 loc) • 2.31 kB
TypeScript
/**
* Entity classification and clustering step implementation
* This module provides advanced entity recognition, classification and clustering
* capabilities to organize research findings into a coherent knowledge graph.
*/
import { createStep } from '../utils/steps.js';
/**
* Options for entity classification
*/
export interface ClassifyOptions {
/**
* Whether to identify and classify entities in the research data
*/
classifyEntities?: boolean;
/**
* Whether to cluster identified entities by relationship
*/
clusterEntities?: boolean;
/**
* Minimum confidence threshold for entity classification (0-1)
*/
confidenceThreshold?: number;
/**
* Custom entity types to identify (in addition to standard types)
*/
customEntityTypes?: string[];
/**
* Maximum number of entities to extract
*/
maxEntities?: number;
/**
* Maximum number of clusters to generate
*/
maxClusters?: number;
/**
* Custom instructions for entity clustering algorithm
*/
clusteringInstructions?: string;
/**
* Retry configuration for LLM calls
*/
retry?: {
/** Maximum number of retries */
maxRetries?: number;
/** Base delay between retries in ms */
baseDelay?: number;
};
}
/**
* Entity object structure
*/
export interface Entity {
name: string;
type: string;
description: string;
confidence: number;
mentions: number;
attributes?: Record<string, any>;
}
/**
* Relationship between entities
*/
export interface EntityRelationship {
source: string;
target: string;
relationship: string;
confidence: number;
}
/**
* Cluster of related entities
*/
export interface EntityCluster {
name: string;
description: string;
entities: string[];
confidence: number;
}
/**
* Classification data structure
*/
export interface ClassificationData {
entities: Record<string, Entity>;
relationships: EntityRelationship[];
clusters: Record<string, EntityCluster>;
}
/**
* Create a classification step
* @param options - Classification options
* @returns A configured classification step
*/
export declare function classify(options?: ClassifyOptions): ReturnType<typeof createStep>;