improvements & cleanup
This commit is contained in:
		
							parent
							
								
									48209c4639
								
							
						
					
					
						commit
						15d302031e
					
				@ -369,6 +369,7 @@ class AIQueryInterface {
 | 
			
		||||
    this.statusInterval = null;
 | 
			
		||||
    this.microTaskInterval = null;
 | 
			
		||||
    this.currentMicroTaskStep = 0;
 | 
			
		||||
    this.lastApiResponse = null;
 | 
			
		||||
    
 | 
			
		||||
    console.log('[AI Interface] Initializing...');
 | 
			
		||||
    this.initializeElements();
 | 
			
		||||
@ -699,6 +700,8 @@ class AIQueryInterface {
 | 
			
		||||
      });
 | 
			
		||||
      
 | 
			
		||||
      const data = await response.json();
 | 
			
		||||
      this.lastApiResponse = data;
 | 
			
		||||
      this.currentRecommendation = data.recommendation;
 | 
			
		||||
      
 | 
			
		||||
      console.log('[AI Interface] Received response:', { 
 | 
			
		||||
        ok: response.ok, 
 | 
			
		||||
@ -1329,26 +1332,54 @@ class AIQueryInterface {
 | 
			
		||||
    
 | 
			
		||||
    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 = {
 | 
			
		||||
      metadata: {
 | 
			
		||||
        timestamp: new Date().toISOString(),
 | 
			
		||||
        version: "1.0",
 | 
			
		||||
        toolsDataHash: "current", // This would come from dataService
 | 
			
		||||
        aiModel: "claude-sonnet-4", // This would come from aiService
 | 
			
		||||
        aiParameters: {},
 | 
			
		||||
        toolsDataHash: toolsDataHash,
 | 
			
		||||
        aiModel: aiModel,
 | 
			
		||||
        aiParameters: aiParameters,
 | 
			
		||||
        userQuery: inputValue,
 | 
			
		||||
        mode: this.currentMode,
 | 
			
		||||
        processingStats: {},
 | 
			
		||||
        processingStats: processingStats,
 | 
			
		||||
        exportedBy: 'ForensicPathways'
 | 
			
		||||
      },
 | 
			
		||||
      recommendation: this.currentRecommendation,
 | 
			
		||||
      auditTrail: this.currentRecommendation.auditTrail || [],
 | 
			
		||||
      rawContext: {
 | 
			
		||||
        selectedTools: [],
 | 
			
		||||
        backgroundKnowledge: [],
 | 
			
		||||
        contextHistory: [],
 | 
			
		||||
        embeddingsSimilarities: {}
 | 
			
		||||
      }
 | 
			
		||||
      rawContext: rawContext
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    const blob = new Blob([JSON.stringify(exportData, null, 2)], {
 | 
			
		||||
@ -1362,7 +1393,12 @@ class AIQueryInterface {
 | 
			
		||||
    a.click();
 | 
			
		||||
    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) {
 | 
			
		||||
 | 
			
		||||
@ -307,6 +307,7 @@ const sortedTags = Object.entries(tagFrequency)
 | 
			
		||||
 | 
			
		||||
<script define:vars={{ toolsData: data.tools, tagFrequency, sortedTags }}>
 | 
			
		||||
  window.toolsData = toolsData;
 | 
			
		||||
  import { isToolHosted } from "../utils/clientUtils.js";
 | 
			
		||||
  
 | 
			
		||||
  document.addEventListener('DOMContentLoaded', () => {
 | 
			
		||||
    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() {
 | 
			
		||||
      const visibleCount = 20;
 | 
			
		||||
      elements.tagCloudItems.forEach((item, index) => {
 | 
			
		||||
 | 
			
		||||
@ -675,6 +675,7 @@ input[type="checkbox"] {
 | 
			
		||||
  border-radius: 0.25rem;
 | 
			
		||||
  font-size: 0.75rem;
 | 
			
		||||
  margin: 0.125rem;
 | 
			
		||||
  max-height: 1.5rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ===================================================================
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user