Normalize completions endpoint base
This commit is contained in:
parent
c622c07c66
commit
0f2f148b71
Notes:
Jordan Wages
2026-01-06 21:41:49 -06:00
This should fix #1.
5 changed files with 64 additions and 12 deletions
|
|
@ -73,6 +73,7 @@
|
|||
<div class="control">
|
||||
<input class="input" type="text" id="endpoint" placeholder="https://api.example.com">
|
||||
</div>
|
||||
<p class="help" id="endpoint-preview"></p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
|
|
|
|||
|
|
@ -99,7 +99,21 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
markDirty();
|
||||
await applyTheme(themeSelect.value);
|
||||
});
|
||||
document.getElementById('endpoint').value = defaults.endpoint || 'http://127.0.0.1:5000/v1/completions';
|
||||
const endpointInput = document.getElementById('endpoint');
|
||||
const endpointPreview = document.getElementById('endpoint-preview');
|
||||
const fallbackEndpoint = 'http://127.0.0.1:5000';
|
||||
const storedEndpoint = defaults.endpoint || fallbackEndpoint;
|
||||
const endpointBase = AiClassifier.normalizeEndpointBase(storedEndpoint) || storedEndpoint;
|
||||
endpointInput.value = endpointBase;
|
||||
|
||||
function updateEndpointPreview() {
|
||||
const resolved = AiClassifier.buildEndpointUrl(endpointInput.value);
|
||||
endpointPreview.textContent = resolved
|
||||
? `Resolved endpoint: ${resolved}`
|
||||
: 'Resolved endpoint: (invalid)';
|
||||
}
|
||||
endpointInput.addEventListener('input', updateEndpointPreview);
|
||||
updateEndpointPreview();
|
||||
|
||||
const templates = {
|
||||
openai: browser.i18n.getMessage('template.openai'),
|
||||
|
|
@ -806,7 +820,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
initialized = true;
|
||||
|
||||
document.getElementById('save').addEventListener('click', async () => {
|
||||
const endpoint = document.getElementById('endpoint').value;
|
||||
const endpoint = endpointInput.value.trim();
|
||||
const templateName = templateSelect.value;
|
||||
const customTemplateText = customTemplate.value;
|
||||
const customSystemPrompt = systemBox.value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue