updt=ate ollama indocker and add plugins
This commit is contained in:
@@ -125,6 +125,19 @@
|
||||
</form>
|
||||
<div id="provider-usage" class="admin-list"></div>
|
||||
</div>
|
||||
|
||||
<div class="admin-card" style="margin-top: 16px;">
|
||||
<header>
|
||||
<h3>Ollama Test</h3>
|
||||
<div class="pill">Testing</div>
|
||||
</header>
|
||||
<p style="margin-top:0; color: var(--muted);">Test the Ollama provider connection. This makes a test request to verify the configuration and API key are working correctly.</p>
|
||||
<div class="admin-actions" style="flex-direction: column; align-items: flex-start; gap: 12px;">
|
||||
<button id="ollama-test-run" class="primary">Run Ollama Test</button>
|
||||
<div id="ollama-test-status" class="status-line"></div>
|
||||
<div id="ollama-test-output" style="width: 100%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -95,6 +95,9 @@
|
||||
externalTestingStatus: document.getElementById('external-testing-status'),
|
||||
externalTestingOutput: document.getElementById('external-testing-output'),
|
||||
externalTestingConfig: document.getElementById('external-testing-config'),
|
||||
ollamaTestRun: document.getElementById('ollama-test-run'),
|
||||
ollamaTestStatus: document.getElementById('ollama-test-status'),
|
||||
ollamaTestOutput: document.getElementById('ollama-test-output'),
|
||||
};
|
||||
console.log('Element check - opencodeBackupForm:', el.opencodeBackupForm);
|
||||
console.log('Element check - opencodeBackup:', el.opencodeBackup);
|
||||
@@ -304,6 +307,145 @@
|
||||
renderExternalTestingConfig(data.config || {});
|
||||
}
|
||||
|
||||
// --- Ollama Test UI ---
|
||||
function setOllamaTestStatus(msg, isError = false) {
|
||||
if (!el.ollamaTestStatus) return;
|
||||
el.ollamaTestStatus.textContent = msg || '';
|
||||
el.ollamaTestStatus.style.color = isError ? 'var(--danger)' : 'inherit';
|
||||
}
|
||||
|
||||
function renderOllamaTestOutput(data) {
|
||||
if (!el.ollamaTestOutput) return;
|
||||
el.ollamaTestOutput.innerHTML = '';
|
||||
if (!data) return;
|
||||
|
||||
// Config section
|
||||
const configSection = document.createElement('div');
|
||||
configSection.style.marginBottom = '16px';
|
||||
configSection.style.padding = '12px';
|
||||
configSection.style.background = 'var(--surface)';
|
||||
configSection.style.borderRadius = '6px';
|
||||
|
||||
const configTitle = document.createElement('div');
|
||||
configTitle.style.fontWeight = '600';
|
||||
configTitle.style.marginBottom = '8px';
|
||||
configTitle.textContent = 'Configuration';
|
||||
configSection.appendChild(configTitle);
|
||||
|
||||
const configRows = [
|
||||
['URL', data.config?.url || '—'],
|
||||
['Model', data.config?.model || '—'],
|
||||
['API Key Configured', data.config?.apiKeyConfigured ? 'Yes' : 'No'],
|
||||
['API Key Preview', data.config?.apiKeyPreview || '—'],
|
||||
];
|
||||
|
||||
configRows.forEach(([label, value]) => {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'admin-row';
|
||||
row.style.marginBottom = '4px';
|
||||
const labelWrap = document.createElement('div');
|
||||
labelWrap.style.minWidth = '140px';
|
||||
labelWrap.style.fontSize = '12px';
|
||||
labelWrap.style.color = 'var(--muted)';
|
||||
labelWrap.textContent = label;
|
||||
const valueWrap = document.createElement('div');
|
||||
valueWrap.style.fontSize = '12px';
|
||||
valueWrap.textContent = value;
|
||||
row.appendChild(labelWrap);
|
||||
row.appendChild(valueWrap);
|
||||
configSection.appendChild(row);
|
||||
});
|
||||
|
||||
el.ollamaTestOutput.appendChild(configSection);
|
||||
|
||||
// Result section
|
||||
if (data.result) {
|
||||
const resultSection = document.createElement('div');
|
||||
resultSection.style.marginBottom = '16px';
|
||||
resultSection.style.padding = '12px';
|
||||
resultSection.style.background = 'rgba(0, 200, 0, 0.1)';
|
||||
resultSection.style.borderRadius = '6px';
|
||||
resultSection.style.border = '1px solid var(--shopify-green)';
|
||||
|
||||
const resultTitle = document.createElement('div');
|
||||
resultTitle.style.fontWeight = '600';
|
||||
resultTitle.style.marginBottom = '8px';
|
||||
resultTitle.style.color = 'var(--shopify-green)';
|
||||
resultTitle.textContent = `✓ Test Passed (${data.duration}ms)`;
|
||||
resultSection.appendChild(resultTitle);
|
||||
|
||||
const resultRows = [
|
||||
['Response', data.result.reply || '—'],
|
||||
['Model Used', data.result.model || '—'],
|
||||
];
|
||||
|
||||
resultRows.forEach(([label, value]) => {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'admin-row';
|
||||
row.style.marginBottom = '4px';
|
||||
const labelWrap = document.createElement('div');
|
||||
labelWrap.style.minWidth = '140px';
|
||||
labelWrap.style.fontSize = '12px';
|
||||
labelWrap.style.color = 'var(--muted)';
|
||||
labelWrap.textContent = label;
|
||||
const valueWrap = document.createElement('div');
|
||||
valueWrap.style.fontSize = '12px';
|
||||
valueWrap.textContent = value;
|
||||
row.appendChild(labelWrap);
|
||||
row.appendChild(valueWrap);
|
||||
resultSection.appendChild(row);
|
||||
});
|
||||
|
||||
el.ollamaTestOutput.appendChild(resultSection);
|
||||
}
|
||||
|
||||
// Error section
|
||||
if (data.error) {
|
||||
const errorSection = document.createElement('div');
|
||||
errorSection.style.marginBottom = '16px';
|
||||
errorSection.style.padding = '12px';
|
||||
errorSection.style.background = 'rgba(255, 0, 0, 0.05)';
|
||||
errorSection.style.borderRadius = '6px';
|
||||
errorSection.style.border = '1px solid var(--danger)';
|
||||
|
||||
const errorTitle = document.createElement('div');
|
||||
errorTitle.style.fontWeight = '600';
|
||||
errorTitle.style.marginBottom = '8px';
|
||||
errorTitle.style.color = 'var(--danger)';
|
||||
errorTitle.textContent = `✗ Test Failed (${data.duration}ms)`;
|
||||
errorSection.appendChild(errorTitle);
|
||||
|
||||
const errorRows = [
|
||||
['Error Message', data.error.message || '—'],
|
||||
['Status Code', data.error.status || '—'],
|
||||
['Detail', data.error.detail || '—'],
|
||||
['Auth Error', data.error.isAuthError ? 'Yes' : 'No'],
|
||||
['Model Missing', data.error.isModelMissing ? 'Yes' : 'No'],
|
||||
['Error Code', data.error.code || '—'],
|
||||
];
|
||||
|
||||
errorRows.forEach(([label, value]) => {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'admin-row';
|
||||
row.style.marginBottom = '4px';
|
||||
const labelWrap = document.createElement('div');
|
||||
labelWrap.style.minWidth = '140px';
|
||||
labelWrap.style.fontSize = '12px';
|
||||
labelWrap.style.color = 'var(--muted)';
|
||||
labelWrap.textContent = label;
|
||||
const valueWrap = document.createElement('div');
|
||||
valueWrap.style.fontSize = '12px';
|
||||
valueWrap.style.color = label === 'Error Message' ? 'var(--danger)' : 'inherit';
|
||||
valueWrap.textContent = value;
|
||||
row.appendChild(labelWrap);
|
||||
row.appendChild(valueWrap);
|
||||
errorSection.appendChild(row);
|
||||
});
|
||||
|
||||
el.ollamaTestOutput.appendChild(errorSection);
|
||||
}
|
||||
}
|
||||
|
||||
async function api(path, options = {}) {
|
||||
const res = await fetch(path, {
|
||||
credentials: 'same-origin',
|
||||
@@ -2282,6 +2424,33 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Ollama Test button handler
|
||||
if (el.ollamaTestRun) {
|
||||
el.ollamaTestRun.addEventListener('click', async () => {
|
||||
el.ollamaTestRun.disabled = true;
|
||||
setOllamaTestStatus('Running Ollama test...');
|
||||
if (el.ollamaTestOutput) el.ollamaTestOutput.innerHTML = '';
|
||||
|
||||
try {
|
||||
const data = await api('/api/admin/ollama-test', { method: 'POST' });
|
||||
renderOllamaTestOutput(data);
|
||||
|
||||
if (data.ok) {
|
||||
setOllamaTestStatus(`Test passed! Response time: ${data.duration}ms`);
|
||||
} else {
|
||||
setOllamaTestStatus(`Test failed: ${data.error?.message || 'Unknown error'}`, true);
|
||||
}
|
||||
} catch (err) {
|
||||
setOllamaTestStatus(err.message || 'Test failed', true);
|
||||
if (el.ollamaTestOutput) {
|
||||
el.ollamaTestOutput.innerHTML = `<div style="color: var(--danger); padding: 12px;">Error: ${err.message || 'Request failed'}</div>`;
|
||||
}
|
||||
} finally {
|
||||
el.ollamaTestRun.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (el.logout) {
|
||||
el.logout.addEventListener('click', async () => {
|
||||
await api('/api/admin/logout', { method: 'POST' }).catch(() => { });
|
||||
|
||||
Reference in New Issue
Block a user