mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
feat: Update LLM base URL configuration and enhance model selection logic
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@ ABOGEN_GID=1000
|
|||||||
# Optional: Seed the web UI with working defaults for the LLM-powered
|
# Optional: Seed the web UI with working defaults for the LLM-powered
|
||||||
# text normalization features. Leave these blank to configure everything
|
# text normalization features. Leave these blank to configure everything
|
||||||
# from the Settings page.
|
# from the Settings page.
|
||||||
ABOGEN_LLM_BASE_URL=https://localhost:11434/v1
|
ABOGEN_LLM_BASE_URL=http://localhost:11434 # Supply the server root; /v1 is added automatically.
|
||||||
ABOGEN_LLM_API_KEY=ollama
|
ABOGEN_LLM_API_KEY=ollama
|
||||||
ABOGEN_LLM_MODEL=llama3.1:8b
|
ABOGEN_LLM_MODEL=llama3.1:8b
|
||||||
ABOGEN_LLM_TIMEOUT=45
|
ABOGEN_LLM_TIMEOUT=45
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ Multiple jobs can run sequentially; the worker processes them in order.
|
|||||||
## LLM-assisted text normalization
|
## LLM-assisted text normalization
|
||||||
Abogen can hand tricky apostrophes and contractions to an OpenAI-compatible large language model. Configure it from **Settings → LLM**:
|
Abogen can hand tricky apostrophes and contractions to an OpenAI-compatible large language model. Configure it from **Settings → LLM**:
|
||||||
|
|
||||||
1. Enter the base URL for your endpoint (Ollama, OpenAI proxy, etc.) and an API key if required.
|
1. Enter the base URL for your endpoint (Ollama, OpenAI proxy, etc.) and an API key if required. Use the server root (for Ollama: `http://localhost:11434`)—Abogen appends `/v1/...` automatically, but it also accepts inputs that already end in `/v1`.
|
||||||
2. Click **Refresh models** to load the catalog, pick a default model, and adjust the timeout or prompt template.
|
2. Click **Refresh models** to load the catalog, pick a default model, and adjust the timeout or prompt template.
|
||||||
3. Use the preview box to test the prompt, then save the settings. The Normalization panel can synthesize a short audio preview with the current configuration.
|
3. Use the preview box to test the prompt, then save the settings. The Normalization panel can synthesize a short audio preview with the current configuration.
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,11 @@ def _normalized_base_url(base_url: str) -> str:
|
|||||||
|
|
||||||
def _build_url(base_url: str, path: str) -> str:
|
def _build_url(base_url: str, path: str) -> str:
|
||||||
normalized = _normalized_base_url(base_url)
|
normalized = _normalized_base_url(base_url)
|
||||||
return parse.urljoin(normalized, path.lstrip("/"))
|
trimmed_path = path.lstrip("/")
|
||||||
|
parsed = parse.urlparse(normalized)
|
||||||
|
if parsed.path.rstrip("/").lower().endswith("/v1") and trimmed_path.startswith("v1/"):
|
||||||
|
trimmed_path = trimmed_path[len("v1/"):]
|
||||||
|
return parse.urljoin(normalized, trimmed_path)
|
||||||
|
|
||||||
|
|
||||||
def _build_headers(api_key: str) -> Dict[str, str]:
|
def _build_headers(api_key: str) -> Dict[str, str]:
|
||||||
|
|||||||
@@ -125,16 +125,36 @@ function updateModelOptions(models) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fragment = document.createDocumentFragment();
|
const fragment = document.createDocumentFragment();
|
||||||
models.forEach((modelName) => {
|
let matchedCurrent = false;
|
||||||
|
models.forEach((entry) => {
|
||||||
|
let identifier = '';
|
||||||
|
let label = '';
|
||||||
|
if (typeof entry === 'string') {
|
||||||
|
identifier = entry;
|
||||||
|
label = entry;
|
||||||
|
} else if (entry && typeof entry === 'object') {
|
||||||
|
identifier = String(entry.id || entry.name || entry.label || '').trim();
|
||||||
|
label = String(entry.label || entry.name || identifier || '').trim();
|
||||||
|
}
|
||||||
|
if (!identifier) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!label) {
|
||||||
|
label = identifier;
|
||||||
|
}
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.value = modelName;
|
option.value = identifier;
|
||||||
option.textContent = modelName;
|
option.textContent = label;
|
||||||
if (modelName === current) {
|
if (identifier === current) {
|
||||||
option.selected = true;
|
option.selected = true;
|
||||||
|
matchedCurrent = true;
|
||||||
}
|
}
|
||||||
fragment.appendChild(option);
|
fragment.appendChild(option);
|
||||||
});
|
});
|
||||||
select.appendChild(fragment);
|
select.appendChild(fragment);
|
||||||
|
if (!matchedCurrent && select.options.length) {
|
||||||
|
select.selectedIndex = 0;
|
||||||
|
}
|
||||||
select.dataset.currentModel = select.value || '';
|
select.dataset.currentModel = select.value || '';
|
||||||
select.disabled = false;
|
select.disabled = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user