cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// src/utils/aiPipeline.ts - Fixed to remove hardcoded values and improve dynamics
|
||||
// src/utils/aiPipeline.ts
|
||||
import { getCompressedToolsDataForAI, getDataVersion } from './dataService.js';
|
||||
import { aiService } from './aiService.js';
|
||||
import { toolSelector, type SelectionContext } from './toolSelector.js';
|
||||
@@ -77,7 +77,6 @@ interface PipelineContext {
|
||||
}>;
|
||||
seenToolNames: Set<string>;
|
||||
embeddingsSimilarities: Map<string, number>;
|
||||
// Add phase metadata for dynamic phase handling
|
||||
phaseMetadata?: {
|
||||
phases: any[];
|
||||
criticalPhaseIds: string[];
|
||||
@@ -128,7 +127,6 @@ class AIPipeline {
|
||||
currentContextLength: 0,
|
||||
seenToolNames: new Set<string>(),
|
||||
embeddingsSimilarities: new Map<string, number>(),
|
||||
// Initialize phase metadata dynamically
|
||||
phaseMetadata: this.initializePhaseMetadata(toolsData.phases)
|
||||
};
|
||||
|
||||
@@ -259,20 +257,17 @@ class AIPipeline {
|
||||
};
|
||||
}
|
||||
|
||||
// Dynamically determine critical phases based on typical_tools or key_activities
|
||||
const criticalPhaseIds = phases
|
||||
.filter(phase => {
|
||||
const typicalToolsCount = phase.typical_tools?.length || 0;
|
||||
const keyActivitiesCount = phase.key_activities?.length || 0;
|
||||
// Consider phases with many tools or activities as critical
|
||||
return typicalToolsCount >= 3 || keyActivitiesCount >= 2;
|
||||
})
|
||||
.map(phase => phase.id);
|
||||
|
||||
// Calculate phase complexity based on metadata
|
||||
const phaseComplexity = new Map<string, number>();
|
||||
phases.forEach(phase => {
|
||||
let complexity = 1; // Base complexity
|
||||
let complexity = 1;
|
||||
|
||||
if (phase.typical_tools?.length > 5) complexity += 1;
|
||||
if (phase.key_activities?.length > 3) complexity += 1;
|
||||
@@ -389,7 +384,6 @@ class AIPipeline {
|
||||
const moderatedTaskRelevance = this.moderateTaskRelevance(sel.taskRelevance);
|
||||
const priority = this.derivePriorityFromScore(moderatedTaskRelevance);
|
||||
|
||||
// Generate dynamic limitations based on context
|
||||
const dynamicLimitations = this.generateDynamicLimitations(tool, phase, sel);
|
||||
|
||||
this.addToolToSelection(context, tool, phase.id, priority, sel.justification, moderatedTaskRelevance, dynamicLimitations);
|
||||
@@ -444,18 +438,15 @@ class AIPipeline {
|
||||
): number {
|
||||
let confidence = 60;
|
||||
|
||||
// Use dynamic phase metadata instead of hardcoded values
|
||||
const isCritical = phaseMetadata?.criticalPhaseIds.includes(phaseId) || false;
|
||||
const phaseComplexity = phaseMetadata?.phaseComplexity.get(phaseId) || 1;
|
||||
|
||||
// Selection made
|
||||
if (selectedCount > 0) {
|
||||
confidence += 20;
|
||||
} else {
|
||||
return 30;
|
||||
}
|
||||
|
||||
// Selection ratio (for phases, 20-50% is reasonable)
|
||||
const ratio = selectedCount / availableCount;
|
||||
if (ratio >= 0.2 && ratio <= 0.5) {
|
||||
confidence += 15;
|
||||
@@ -463,17 +454,14 @@ class AIPipeline {
|
||||
confidence += 10;
|
||||
}
|
||||
|
||||
// Dynamic critical phase handling
|
||||
if (isCritical && selectedCount >= 2) {
|
||||
confidence += 10;
|
||||
}
|
||||
|
||||
// Phase complexity factor
|
||||
if (phaseComplexity > 2 && selectedCount >= phaseComplexity) {
|
||||
confidence += 5;
|
||||
}
|
||||
|
||||
// Quality of selections (based on task relevance)
|
||||
const avgRelevance = selections.length > 0 ?
|
||||
selections.reduce((sum, s) => sum + (s.taskRelevance || 70), 0) / selections.length : 0;
|
||||
|
||||
@@ -489,12 +477,10 @@ class AIPipeline {
|
||||
private generateDynamicLimitations(tool: any, phase: any, selection: any): string[] {
|
||||
const limitations: string[] = [];
|
||||
|
||||
// Add existing limitations if provided
|
||||
if (selection.limitations && Array.isArray(selection.limitations)) {
|
||||
limitations.push(...selection.limitations);
|
||||
}
|
||||
|
||||
// Generate context-aware limitations
|
||||
if (tool.type === 'software' && !tool.projectUrl) {
|
||||
limitations.push('Installation und Konfiguration erforderlich');
|
||||
}
|
||||
@@ -507,12 +493,11 @@ class AIPipeline {
|
||||
limitations.push('Kommerzielle Lizenz erforderlich');
|
||||
}
|
||||
|
||||
// Phase-specific limitations
|
||||
if (phase.id === 'acquisition' && tool.type === 'method') {
|
||||
limitations.push('Sorgfältige Dokumentation für Chain of Custody erforderlich');
|
||||
}
|
||||
|
||||
return limitations.slice(0, 3); // Limit to 3 most relevant
|
||||
return limitations.slice(0, 3);
|
||||
}
|
||||
|
||||
private async processToolMode(
|
||||
@@ -699,7 +684,6 @@ class AIPipeline {
|
||||
moderatedTaskRelevance = this.moderateTaskRelevance(75);
|
||||
}
|
||||
|
||||
// Generate dynamic limitations instead of hardcoded ones
|
||||
const dynamicLimitations = this.generateCompletionLimitations(tool, phase, selection);
|
||||
|
||||
this.addToolToSelection(
|
||||
@@ -754,10 +738,8 @@ class AIPipeline {
|
||||
private generateCompletionLimitations(tool: any, phase: any, selection: any): string[] {
|
||||
const limitations: string[] = [];
|
||||
|
||||
// Context-specific limitation for completion tools
|
||||
limitations.push('Nachträgliche Ergänzung - ursprünglich nicht als Hauptmethode identifiziert');
|
||||
|
||||
// Tool-specific limitations
|
||||
if (tool.skillLevel === 'expert') {
|
||||
limitations.push('Erfordert Expertenwissen für optimale Nutzung');
|
||||
}
|
||||
@@ -766,7 +748,6 @@ class AIPipeline {
|
||||
limitations.push('Zusätzliche Setup-Zeit erforderlich');
|
||||
}
|
||||
|
||||
// Phase-specific context
|
||||
if (phase.typical_tools && !phase.typical_tools.includes(tool.name)) {
|
||||
limitations.push(`Nicht typisch für ${phase.name}-Phase - alternative Anwendung`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user