semantic search finalization
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
---
|
||||
// src/components/AIQueryInterface.astro
|
||||
|
||||
import { getToolsData } from '../utils/dataService.js';
|
||||
import { isToolHosted } from '../utils/toolHelpers.js';
|
||||
import { AuditTrailRenderer } from '../js/auditTrailRenderer.js';
|
||||
|
||||
const data = await getToolsData();
|
||||
const tools = data.tools;
|
||||
@@ -207,16 +210,22 @@ const domainAgnosticSoftware = data['domain-agnostic-software'] || [];
|
||||
</div>
|
||||
|
||||
<!-- Results -->
|
||||
<div id="ai-results" class="ai-results hidden"></div>
|
||||
<div id="ai-results" class="ai-results hidden">
|
||||
<!-- Audit trail container - managed by AuditTrailRenderer -->
|
||||
<div id="audit-trail-container"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script define:vars={{ tools, phases, domainAgnosticSoftware }}>
|
||||
<script type="module" define:vars={{ tools, phases, domainAgnosticSoftware }}>
|
||||
import { AuditTrailRenderer } from '../js/auditTrailRenderer.js';
|
||||
|
||||
|
||||
class AIQueryInterface {
|
||||
constructor() {
|
||||
this.currentMode = 'workflow';
|
||||
this.currentRecommendation = null;
|
||||
this.auditTrailRenderer = null;
|
||||
this.enhancementTimeout = null;
|
||||
this.enhancementAbortController = null;
|
||||
this.statusInterval = null;
|
||||
@@ -519,7 +528,7 @@ class AIQueryInterface {
|
||||
}
|
||||
|
||||
this.currentRecommendation = data.recommendation;
|
||||
this.displayResults(data.recommendation, query);
|
||||
await this.displayResults(data.recommendation, query);
|
||||
|
||||
} catch (error) {
|
||||
console.error('[AI Interface] Request failed:', error);
|
||||
@@ -671,26 +680,31 @@ class AIQueryInterface {
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
displayResults(recommendation, originalQuery) {
|
||||
async displayResults(recommendation, originalQuery) {
|
||||
console.log('[AI DEBUG] Full recommendation object:', recommendation);
|
||||
console.log('[AI DEBUG] Recommended tools:', recommendation.recommended_tools);
|
||||
|
||||
if (recommendation.recommended_tools) {
|
||||
recommendation.recommended_tools.forEach((tool, index) => {
|
||||
console.log(`[AI DEBUG] Tool ${index}:`, tool.name, 'Confidence:', tool.confidence);
|
||||
});
|
||||
}
|
||||
console.log('[AI DEBUG] Audit trail data:', recommendation.auditTrail);
|
||||
|
||||
if (this.currentMode === 'workflow') {
|
||||
this.displayWorkflowResults(recommendation, originalQuery);
|
||||
await this.displayWorkflowResults(recommendation, originalQuery);
|
||||
} else {
|
||||
this.displayToolResults(recommendation, originalQuery);
|
||||
await this.displayToolResults(recommendation, originalQuery);
|
||||
}
|
||||
|
||||
// Show results first, then render audit trail
|
||||
this.showResults();
|
||||
|
||||
// Render audit trail after DOM is ready
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
await this.renderAuditTrail(recommendation.auditTrail);
|
||||
console.log('[AI DEBUG] Audit trail rendered successfully');
|
||||
} catch (error) {
|
||||
console.error('[AI DEBUG] Failed to render audit trail:', error);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
displayWorkflowResults(recommendation, originalQuery) {
|
||||
async displayWorkflowResults(recommendation, originalQuery) {
|
||||
const toolsByPhase = {};
|
||||
const phaseOrder = phases.map(phase => phase.id);
|
||||
const phaseNames = phases.reduce((acc, phase) => {
|
||||
@@ -730,14 +744,16 @@ class AIQueryInterface {
|
||||
${this.renderBackgroundKnowledge(recommendation.background_knowledge)}
|
||||
${this.renderWorkflowPhases(toolsByPhase, phaseOrder, phaseNames)}
|
||||
${this.renderWorkflowSuggestion(recommendation.workflow_suggestion)}
|
||||
${this.renderAuditTrail(recommendation.auditTrail)}
|
||||
</div>
|
||||
|
||||
<div id="audit-trail-container"></div>
|
||||
`;
|
||||
|
||||
this.elements.results.innerHTML = html;
|
||||
await this.renderAuditTrail(recommendation.auditTrail);
|
||||
}
|
||||
|
||||
displayToolResults(recommendation, originalQuery) {
|
||||
async displayToolResults(recommendation, originalQuery) {
|
||||
const html = `
|
||||
<div class="workflow-container">
|
||||
${this.renderHeader('Handlungsempfehlung', originalQuery)}
|
||||
@@ -745,11 +761,12 @@ class AIQueryInterface {
|
||||
${this.renderBackgroundKnowledge(recommendation.background_knowledge)}
|
||||
${this.renderToolRecommendations(recommendation.recommended_tools)}
|
||||
${this.renderAdditionalConsiderations(recommendation.additional_considerations)}
|
||||
${this.renderAuditTrail(recommendation.auditTrail)}
|
||||
</div>
|
||||
<div id="audit-trail-container"></div>
|
||||
`;
|
||||
|
||||
this.elements.results.innerHTML = html;
|
||||
await this.renderAuditTrail(recommendation.auditTrail);
|
||||
}
|
||||
|
||||
renderConfidenceTooltip(confidence) {
|
||||
@@ -829,209 +846,68 @@ class AIQueryInterface {
|
||||
`;
|
||||
}
|
||||
|
||||
renderAuditTrail(auditTrail) {
|
||||
if (!auditTrail || !Array.isArray(auditTrail) || auditTrail.length === 0) {
|
||||
return '';
|
||||
async renderAuditTrail(rawAuditTrail) {
|
||||
console.log('[AI Interface] Starting audit trail render...', rawAuditTrail?.length || 0, 'entries');
|
||||
|
||||
const container = document.getElementById('audit-trail-container');
|
||||
if (!container) {
|
||||
console.error('[AI Interface] Audit container not found');
|
||||
return;
|
||||
}
|
||||
|
||||
const totalTime = auditTrail.reduce((sum, entry) => sum + entry.processingTimeMs, 0);
|
||||
const avgConfidence = auditTrail.reduce((sum, entry) => sum + entry.confidence, 0) / auditTrail.length;
|
||||
const lowConfidenceSteps = auditTrail.filter(entry => entry.confidence < 60).length;
|
||||
const highConfidenceSteps = auditTrail.filter(entry => entry.confidence >= 80).length;
|
||||
|
||||
const groupedEntries = auditTrail.reduce((groups, entry) => {
|
||||
if (!groups[entry.phase]) groups[entry.phase] = [];
|
||||
groups[entry.phase].push(entry);
|
||||
return groups;
|
||||
}, {});
|
||||
|
||||
return `
|
||||
<div class="card-info-sm mt-4" style="border-left: 4px solid var(--color-accent);">
|
||||
<div class="flex items-center justify-between mb-3 cursor-pointer" onclick="const container = this.closest('.card-info-sm'); const details = container.querySelector('.audit-trail-details'); const isHidden = details.style.display === 'none'; details.style.display = isHidden ? 'block' : 'none'; this.querySelector('.toggle-icon').style.transform = isHidden ? 'rotate(180deg)' : 'rotate(0deg)';">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<div style="width: 24px; height: 24px; background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-primary) 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 0.75rem; font-weight: bold;">
|
||||
✓
|
||||
</div>
|
||||
<h4 class="text-sm font-semibold text-accent mb-0">KI-Entscheidungspfad</h4>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 text-xs">
|
||||
<div class="flex items-center gap-1">
|
||||
<div class="w-2 h-2 rounded-full" style="background-color: var(--color-accent);"></div>
|
||||
<span class="text-muted">${this.formatDuration(totalTime)}</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<div class="w-2 h-2 rounded-full" style="background-color: ${avgConfidence >= 80 ? 'var(--color-accent)' : avgConfidence >= 60 ? 'var(--color-warning)' : 'var(--color-error)'};"></div>
|
||||
<span class="text-muted">${Math.round(avgConfidence)}% Vertrauen</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<span class="text-muted">${auditTrail.length} Schritte</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toggle-icon" style="transition: transform 0.2s ease;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="6 9 12 15 18 9"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: none;" class="audit-trail-details">
|
||||
<div class="grid gap-4">
|
||||
<!-- Summary Section -->
|
||||
<div class="p-3 rounded-lg" style="background-color: var(--color-bg-tertiary);">
|
||||
<div class="text-xs font-medium mb-2 text-accent">📊 Analyse-Qualität</div>
|
||||
<div class="grid grid-cols-3 gap-3 text-xs">
|
||||
<div class="text-center">
|
||||
<div class="font-semibold" style="color: var(--color-accent);">${highConfidenceSteps}</div>
|
||||
<div class="text-muted">Hohe Sicherheit</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="font-semibold" style="color: ${lowConfidenceSteps > 0 ? 'var(--color-warning)' : 'var(--color-accent)'};">${lowConfidenceSteps}</div>
|
||||
<div class="text-muted">Unsichere Schritte</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="font-semibold">${this.formatDuration(totalTime)}</div>
|
||||
<div class="text-muted">Verarbeitungszeit</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Process Flow -->
|
||||
<div class="audit-process-flow">
|
||||
${Object.entries(groupedEntries).map(([phase, entries]) => this.renderPhaseGroup(phase, entries)).join('')}
|
||||
</div>
|
||||
|
||||
<!-- Technical Details Toggle -->
|
||||
<div class="text-center">
|
||||
<button class="text-xs text-muted hover:text-primary transition-colors cursor-pointer border-none bg-none" onclick="const techDetails = this.nextElementSibling; const isHidden = techDetails.style.display === 'none'; techDetails.style.display = isHidden ? 'block' : 'none'; this.textContent = isHidden ? '🔧 Technische Details ausblenden' : '🔧 Technische Details anzeigen';">
|
||||
🔧 Technische Details anzeigen
|
||||
</button>
|
||||
<div style="display: none;" class="mt-3 p-3 rounded-lg bg-gray-50 dark:bg-gray-800 text-xs">
|
||||
${auditTrail.map(entry => this.renderTechnicalEntry(entry)).join('')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
renderPhaseGroup(phase, entries) {
|
||||
const phaseIcons = {
|
||||
'initialization': '🚀',
|
||||
'retrieval': '🔍',
|
||||
'selection': '🎯',
|
||||
'micro-task': '⚡',
|
||||
'completion': '✅'
|
||||
};
|
||||
|
||||
const phaseNames = {
|
||||
'initialization': 'Initialisierung',
|
||||
'retrieval': 'Datensuche',
|
||||
'selection': 'Tool-Auswahl',
|
||||
'micro-task': 'Detail-Analyse',
|
||||
'completion': 'Finalisierung'
|
||||
};
|
||||
|
||||
const avgConfidence = entries.reduce((sum, entry) => sum + entry.confidence, 0) / entries.length;
|
||||
const totalTime = entries.reduce((sum, entry) => sum + entry.processingTimeMs, 0);
|
||||
|
||||
return `
|
||||
<div class="phase-group mb-4">
|
||||
<div class="flex items-center gap-3 mb-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-lg">${phaseIcons[phase] || '📋'}</span>
|
||||
<span class="font-medium text-sm">${phaseNames[phase] || phase}</span>
|
||||
</div>
|
||||
<div class="flex-1 h-px bg-border"></div>
|
||||
<div class="flex items-center gap-2 text-xs text-muted">
|
||||
<div class="confidence-indicator w-12 h-2 rounded-full overflow-hidden" style="background-color: var(--color-bg-tertiary);">
|
||||
<div class="h-full rounded-full transition-all" style="width: ${avgConfidence}%; background-color: ${avgConfidence >= 80 ? 'var(--color-accent)' : avgConfidence >= 60 ? 'var(--color-warning)' : 'var(--color-error)'};"></div>
|
||||
// Clear previous content
|
||||
container.innerHTML = '';
|
||||
|
||||
// Check if we have audit data
|
||||
if (!rawAuditTrail || !Array.isArray(rawAuditTrail) || rawAuditTrail.length === 0) {
|
||||
console.log('[AI Interface] No audit trail data to render');
|
||||
container.innerHTML = `
|
||||
<div class="audit-trail-container">
|
||||
<div class="audit-trail-header">
|
||||
<div class="audit-icon">
|
||||
<div class="audit-icon-gradient">ⓘ</div>
|
||||
<h4>Kein Audit-Trail verfügbar</h4>
|
||||
</div>
|
||||
<span>${Math.round(avgConfidence)}%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-2 ml-6">
|
||||
${entries.map(entry => this.renderSimplifiedEntry(entry)).join('')}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
renderSimplifiedEntry(entry) {
|
||||
const actionIcons = {
|
||||
'pipeline-start': '▶️',
|
||||
'embeddings-search': '🔍',
|
||||
'ai-tool-selection': '🎯',
|
||||
'ai-analysis': '🧠',
|
||||
'phase-tool-selection': '⚙️',
|
||||
'tool-evaluation': '📊',
|
||||
'background-knowledge-selection': '📚',
|
||||
'pipeline-end': '🏁'
|
||||
};
|
||||
|
||||
const actionNames = {
|
||||
'pipeline-start': 'Analyse gestartet',
|
||||
'embeddings-search': 'Ähnliche Tools gesucht',
|
||||
'ai-tool-selection': 'Tools automatisch ausgewählt',
|
||||
'ai-analysis': 'KI-Analyse durchgeführt',
|
||||
'phase-tool-selection': 'Phasen-Tools evaluiert',
|
||||
'tool-evaluation': 'Tool-Bewertung erstellt',
|
||||
'background-knowledge-selection': 'Hintergrundwissen ausgewählt',
|
||||
'pipeline-end': 'Analyse abgeschlossen'
|
||||
};
|
||||
|
||||
const confidenceColor = entry.confidence >= 80 ? 'var(--color-accent)' :
|
||||
entry.confidence >= 60 ? 'var(--color-warning)' : 'var(--color-error)';
|
||||
|
||||
return `
|
||||
<div class="flex items-center gap-3 py-2 px-3 rounded-lg hover:bg-secondary transition-colors">
|
||||
<span class="text-sm">${actionIcons[entry.action] || '📋'}</span>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="text-sm font-medium">${actionNames[entry.action] || entry.action}</div>
|
||||
${entry.output && typeof entry.output === 'object' && entry.output.selectedToolCount ?
|
||||
`<div class="text-xs text-muted">${entry.output.selectedToolCount} Tools ausgewählt</div>` : ''}
|
||||
</div>
|
||||
<div class="flex items-center gap-2 text-xs">
|
||||
<div class="w-8 h-1.5 rounded-full overflow-hidden" style="background-color: var(--color-bg-tertiary);">
|
||||
<div class="h-full rounded-full" style="width: ${entry.confidence}%; background-color: ${confidenceColor};"></div>
|
||||
try {
|
||||
// Import and create renderer
|
||||
//const { AuditTrailRenderer } = await import('../js/auditTrailRenderer.js');
|
||||
|
||||
const renderer = new AuditTrailRenderer('audit-trail-container', {
|
||||
title: 'KI-Entscheidungspfad',
|
||||
collapsible: true,
|
||||
defaultExpanded: false
|
||||
});
|
||||
|
||||
// Render synchronously (the method handles async internally)
|
||||
renderer.render(rawAuditTrail);
|
||||
|
||||
console.log('[AI Interface] Audit trail render completed');
|
||||
|
||||
} catch (error) {
|
||||
console.error('[AI Interface] Failed to render audit trail:', error);
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="audit-trail-container">
|
||||
<div class="audit-trail-header">
|
||||
<div class="audit-icon">
|
||||
<div class="audit-icon-gradient" style="background: var(--color-error);">✗</div>
|
||||
<h4>Audit-Trail Fehler</h4>
|
||||
</div>
|
||||
</div>
|
||||
<span class="text-muted w-8 text-right">${entry.confidence}%</span>
|
||||
<span class="text-muted w-12 text-right">${entry.processingTimeMs}ms</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
renderTechnicalEntry(entry) {
|
||||
const formattedTime = new Date(entry.timestamp).toLocaleTimeString('de-DE', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
});
|
||||
|
||||
return `
|
||||
<div class="border rounded p-2 mb-2" style="border-color: var(--color-border);">
|
||||
<div class="flex justify-between items-center mb-1">
|
||||
<span class="font-mono text-xs">${entry.phase}/${entry.action}</span>
|
||||
<span class="text-xs text-muted">${formattedTime} • ${entry.processingTimeMs}ms</span>
|
||||
</div>
|
||||
${entry.input && Object.keys(entry.input).length > 0 ? `
|
||||
<div class="text-xs mb-1">
|
||||
<strong>Input:</strong> ${this.formatAuditData(entry.input)}
|
||||
<div class="audit-summary">
|
||||
<p style="color: var(--color-error);">
|
||||
Fehler beim Laden der Audit-Informationen: ${error.message}
|
||||
</p>
|
||||
</div>
|
||||
` : ''}
|
||||
${entry.output && Object.keys(entry.output).length > 0 ? `
|
||||
<div class="text-xs">
|
||||
<strong>Output:</strong> ${this.formatAuditData(entry.output)}
|
||||
</div>
|
||||
` : ''}
|
||||
</div>
|
||||
`;
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
renderAuditEntry(entry) {
|
||||
@@ -1069,29 +945,6 @@ class AIQueryInterface {
|
||||
`;
|
||||
}
|
||||
|
||||
formatAuditData(data) {
|
||||
if (data === null || data === undefined) return 'null';
|
||||
if (typeof data === 'string') {
|
||||
return data.length > 100 ? data.slice(0, 100) + '...' : data;
|
||||
}
|
||||
if (typeof data === 'number') return data.toString();
|
||||
if (typeof data === 'boolean') return data.toString();
|
||||
if (Array.isArray(data)) {
|
||||
if (data.length === 0) return '[]';
|
||||
if (data.length <= 3) return JSON.stringify(data);
|
||||
return `[${data.slice(0, 3).map(i => typeof i === 'string' ? i : JSON.stringify(i)).join(', ')}, ...+${data.length - 3}]`;
|
||||
}
|
||||
if (typeof data === 'object') {
|
||||
const keys = Object.keys(data);
|
||||
if (keys.length === 0) return '{}';
|
||||
if (keys.length <= 3) {
|
||||
return '{' + keys.map(k => `${k}: ${typeof data[k] === 'string' ? data[k].slice(0, 20) + (data[k].length > 20 ? '...' : '') : JSON.stringify(data[k])}`).join(', ') + '}';
|
||||
}
|
||||
return `{${keys.slice(0, 3).join(', ')}, ...+${keys.length - 3} keys}`;
|
||||
}
|
||||
return String(data);
|
||||
}
|
||||
|
||||
renderWorkflowTool(tool) {
|
||||
const hasValidProjectUrl = isToolHosted(tool);
|
||||
const priorityColors = {
|
||||
@@ -1522,6 +1375,23 @@ class AIQueryInterface {
|
||||
return baseText;
|
||||
}
|
||||
|
||||
restoreAIResults() {
|
||||
if (this.currentRecommendation && this.elements.results) {
|
||||
this.showResults();
|
||||
|
||||
// Re-render audit trail if it exists
|
||||
if (this.currentRecommendation.auditTrail) {
|
||||
setTimeout(() => {
|
||||
this.renderAuditTrail(this.currentRecommendation.auditTrail);
|
||||
console.log('[AI Interface] Audit trail restored successfully');
|
||||
}, 100);
|
||||
}
|
||||
|
||||
this.hideLoading();
|
||||
this.hideError();
|
||||
}
|
||||
}
|
||||
|
||||
escapeHtml(text) {
|
||||
if (typeof text !== 'string') return '';
|
||||
const div = document.createElement('div');
|
||||
@@ -1584,13 +1454,28 @@ class AIQueryInterface {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const aiInterface = new AIQueryInterface();
|
||||
|
||||
// FIXED: Global restoreAIResults function with proper error handling
|
||||
window.restoreAIResults = () => {
|
||||
if (aiInterface.currentRecommendation && aiInterface.elements.results) {
|
||||
aiInterface.showResults();
|
||||
|
||||
// Re-render audit trail if it exists
|
||||
if (aiInterface.currentRecommendation.auditTrail) {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
aiInterface.renderAuditTrail(aiInterface.currentRecommendation.auditTrail);
|
||||
console.log('[AI Interface] Global audit trail restored');
|
||||
} catch (error) {
|
||||
console.error('[AI Interface] Global audit trail restore failed:', error);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
aiInterface.hideLoading();
|
||||
aiInterface.hideError();
|
||||
}
|
||||
};
|
||||
window.isToolHosted = window.isToolHosted || isToolHosted
|
||||
|
||||
window.isToolHosted = window.isToolHosted || isToolHosted;
|
||||
});
|
||||
</script>
|
||||
@@ -55,7 +55,7 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
<!-- Semantic Search Toggle - Inline -->
|
||||
<div id="semantic-search-container" class="semantic-search-inline hidden">
|
||||
<label class="semantic-toggle-wrapper" title="Semantische Suche verwendet Embeddings. Dadurch kann mit natürlicher Sprache/Begriffen gesucht werden, die Ergebnisse richten sich nach der euklidischen Distanz.">
|
||||
<input type="checkbox" id="semantic-search-enabled" />
|
||||
<input type="checkbox" id="semantic-search-enabled" disabled/>
|
||||
<div class="semantic-checkbox-custom"></div>
|
||||
<span class="semantic-toggle-label">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
@@ -357,20 +357,17 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
// Check embeddings availability
|
||||
async function checkEmbeddingsAvailability() {
|
||||
try {
|
||||
const response = await fetch('/api/ai/embeddings-status');
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
semanticSearchAvailable = data.embeddings?.enabled && data.embeddings?.initialized;
|
||||
|
||||
if (semanticSearchAvailable && elements.semanticContainer) {
|
||||
const res = await fetch('/api/ai/embeddings-status');
|
||||
const { embeddings } = await res.json();
|
||||
semanticSearchAvailable = embeddings?.enabled && embeddings?.initialized;
|
||||
|
||||
if (semanticSearchAvailable) {
|
||||
elements.semanticContainer.classList.remove('hidden');
|
||||
elements.semanticCheckbox.disabled = false; // 👈 re-enable
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[EMBEDDINGS] Status check failed:', error.message);
|
||||
semanticSearchAvailable = false;
|
||||
} catch (err) {
|
||||
console.error('[EMBEDDINGS] Status check failed:', err);
|
||||
// leave the checkbox disabled
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user