improvements & cleanup
This commit is contained in:
		
							parent
							
								
									48209c4639
								
							
						
					
					
						commit
						15d302031e
					
				@ -369,6 +369,7 @@ class AIQueryInterface {
 | 
				
			|||||||
    this.statusInterval = null;
 | 
					    this.statusInterval = null;
 | 
				
			||||||
    this.microTaskInterval = null;
 | 
					    this.microTaskInterval = null;
 | 
				
			||||||
    this.currentMicroTaskStep = 0;
 | 
					    this.currentMicroTaskStep = 0;
 | 
				
			||||||
 | 
					    this.lastApiResponse = null;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    console.log('[AI Interface] Initializing...');
 | 
					    console.log('[AI Interface] Initializing...');
 | 
				
			||||||
    this.initializeElements();
 | 
					    this.initializeElements();
 | 
				
			||||||
@ -699,6 +700,8 @@ class AIQueryInterface {
 | 
				
			|||||||
      });
 | 
					      });
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      const data = await response.json();
 | 
					      const data = await response.json();
 | 
				
			||||||
 | 
					      this.lastApiResponse = data;
 | 
				
			||||||
 | 
					      this.currentRecommendation = data.recommendation;
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      console.log('[AI Interface] Received response:', { 
 | 
					      console.log('[AI Interface] Received response:', { 
 | 
				
			||||||
        ok: response.ok, 
 | 
					        ok: response.ok, 
 | 
				
			||||||
@ -1329,26 +1332,54 @@ class AIQueryInterface {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    const inputValue = this.elements.input ? this.elements.input.value : '';
 | 
					    const inputValue = this.elements.input ? this.elements.input.value : '';
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    // Extract real data from the current recommendation and stored response
 | 
				
			||||||
 | 
					    const processingStats = this.currentRecommendation.processingStats || {};
 | 
				
			||||||
 | 
					    const aiModel = processingStats.aiModel || 'unknown';
 | 
				
			||||||
 | 
					    const toolsDataHash = processingStats.toolsDataHash || 'unknown';
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    // Get real AI parameters from the processing stats
 | 
				
			||||||
 | 
					    const aiParameters = {
 | 
				
			||||||
 | 
					      maxTokens: processingStats.maxTokensUsed || 0,
 | 
				
			||||||
 | 
					      temperature: processingStats.temperature || 0.3,
 | 
				
			||||||
 | 
					      totalTokensUsed: processingStats.totalAITokensUsed || 0,
 | 
				
			||||||
 | 
					      microTasksCompleted: processingStats.microTasksCompleted || 0,
 | 
				
			||||||
 | 
					      microTasksFailed: processingStats.microTasksFailed || 0,
 | 
				
			||||||
 | 
					      embeddingsUsed: processingStats.embeddingsUsed || false
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    // Extract real context data from the recommendation
 | 
				
			||||||
 | 
					    const rawContext = {
 | 
				
			||||||
 | 
					      selectedTools: this.currentRecommendation.recommended_tools?.map(tool => ({
 | 
				
			||||||
 | 
					        name: tool.name,
 | 
				
			||||||
 | 
					        type: tool.type,
 | 
				
			||||||
 | 
					        phase: tool.phase,
 | 
				
			||||||
 | 
					        priority: tool.priority,
 | 
				
			||||||
 | 
					        confidence: tool.confidence,
 | 
				
			||||||
 | 
					        justification: tool.justification
 | 
				
			||||||
 | 
					      })) || [],
 | 
				
			||||||
 | 
					      backgroundKnowledge: this.currentRecommendation.background_knowledge?.map(bg => ({
 | 
				
			||||||
 | 
					        concept_name: bg.concept_name,
 | 
				
			||||||
 | 
					        relevance: bg.relevance
 | 
				
			||||||
 | 
					      })) || [],
 | 
				
			||||||
 | 
					      contextHistory: [], // This would need to be passed from server if needed
 | 
				
			||||||
 | 
					      embeddingsSimilarities: {} // This would need to be passed from server if needed
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    const exportData = {
 | 
					    const exportData = {
 | 
				
			||||||
      metadata: {
 | 
					      metadata: {
 | 
				
			||||||
        timestamp: new Date().toISOString(),
 | 
					        timestamp: new Date().toISOString(),
 | 
				
			||||||
        version: "1.0",
 | 
					        version: "1.0",
 | 
				
			||||||
        toolsDataHash: "current", // This would come from dataService
 | 
					        toolsDataHash: toolsDataHash,
 | 
				
			||||||
        aiModel: "claude-sonnet-4", // This would come from aiService
 | 
					        aiModel: aiModel,
 | 
				
			||||||
        aiParameters: {},
 | 
					        aiParameters: aiParameters,
 | 
				
			||||||
        userQuery: inputValue,
 | 
					        userQuery: inputValue,
 | 
				
			||||||
        mode: this.currentMode,
 | 
					        mode: this.currentMode,
 | 
				
			||||||
        processingStats: {},
 | 
					        processingStats: processingStats,
 | 
				
			||||||
        exportedBy: 'ForensicPathways'
 | 
					        exportedBy: 'ForensicPathways'
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      recommendation: this.currentRecommendation,
 | 
					      recommendation: this.currentRecommendation,
 | 
				
			||||||
      auditTrail: this.currentRecommendation.auditTrail || [],
 | 
					      auditTrail: this.currentRecommendation.auditTrail || [],
 | 
				
			||||||
      rawContext: {
 | 
					      rawContext: rawContext
 | 
				
			||||||
        selectedTools: [],
 | 
					 | 
				
			||||||
        backgroundKnowledge: [],
 | 
					 | 
				
			||||||
        contextHistory: [],
 | 
					 | 
				
			||||||
        embeddingsSimilarities: {}
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    const blob = new Blob([JSON.stringify(exportData, null, 2)], {
 | 
					    const blob = new Blob([JSON.stringify(exportData, null, 2)], {
 | 
				
			||||||
@ -1362,7 +1393,12 @@ class AIQueryInterface {
 | 
				
			|||||||
    a.click();
 | 
					    a.click();
 | 
				
			||||||
    URL.revokeObjectURL(url);
 | 
					    URL.revokeObjectURL(url);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    console.log('[AI Interface] Analysis downloaded');
 | 
					    console.log('[AI Interface] Analysis downloaded with real metadata:', {
 | 
				
			||||||
 | 
					      aiModel,
 | 
				
			||||||
 | 
					      toolsDataHash: toolsDataHash.slice(0, 8) + '...',
 | 
				
			||||||
 | 
					      tokensUsed: aiParameters.totalTokensUsed,
 | 
				
			||||||
 | 
					      auditEntries: exportData.auditTrail.length
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  validateUploadStructure(data) {
 | 
					  validateUploadStructure(data) {
 | 
				
			||||||
 | 
				
			|||||||
@ -307,6 +307,7 @@ const sortedTags = Object.entries(tagFrequency)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<script define:vars={{ toolsData: data.tools, tagFrequency, sortedTags }}>
 | 
					<script define:vars={{ toolsData: data.tools, tagFrequency, sortedTags }}>
 | 
				
			||||||
  window.toolsData = toolsData;
 | 
					  window.toolsData = toolsData;
 | 
				
			||||||
 | 
					  import { isToolHosted } from "../utils/clientUtils.js";
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  document.addEventListener('DOMContentLoaded', () => {
 | 
					  document.addEventListener('DOMContentLoaded', () => {
 | 
				
			||||||
    const elements = {
 | 
					    const elements = {
 | 
				
			||||||
@ -433,13 +434,6 @@ const sortedTags = Object.entries(tagFrequency)
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    function isToolHosted(tool) {
 | 
					 | 
				
			||||||
      return tool.projectUrl !== undefined && 
 | 
					 | 
				
			||||||
             tool.projectUrl !== null && 
 | 
					 | 
				
			||||||
             tool.projectUrl !== "" && 
 | 
					 | 
				
			||||||
             tool.projectUrl.trim() !== "";
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    function initTagCloud() {
 | 
					    function initTagCloud() {
 | 
				
			||||||
      const visibleCount = 20;
 | 
					      const visibleCount = 20;
 | 
				
			||||||
      elements.tagCloudItems.forEach((item, index) => {
 | 
					      elements.tagCloudItems.forEach((item, index) => {
 | 
				
			||||||
 | 
				
			|||||||
@ -675,6 +675,7 @@ input[type="checkbox"] {
 | 
				
			|||||||
  border-radius: 0.25rem;
 | 
					  border-radius: 0.25rem;
 | 
				
			||||||
  font-size: 0.75rem;
 | 
					  font-size: 0.75rem;
 | 
				
			||||||
  margin: 0.125rem;
 | 
					  margin: 0.125rem;
 | 
				
			||||||
 | 
					  max-height: 1.5rem;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ===================================================================
 | 
					/* ===================================================================
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user