mirror of
https://github.com/open-webui/computer.git
synced 2026-11-24 22:37:40 -05:00
refac
This commit is contained in:
1 parent
6d34d42ee6
commit
482f456688
4 files changed
+29
-4
No files matched your search
@@ -156,6 +156,7 @@
|
||||
<label class="text-[10px] text-gray-400 dark:text-gray-600 mt-2"
|
||||
>{$t('connections.models')}</label
|
||||
>
|
||||
<p class="text-[10px] text-gray-300 dark:text-gray-700 mb-0.5">{$t('connections.modelsHint')}</p>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="claude-sonnet-4-20250514, claude-opus-4-20250514"
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
.split(',')
|
||||
.map((m) => m.trim())
|
||||
.filter(Boolean)
|
||||
: undefined;
|
||||
: [];
|
||||
const name =
|
||||
formName.trim() ||
|
||||
(() => {
|
||||
@@ -192,6 +192,7 @@
|
||||
<label class="text-[10px] text-gray-400 dark:text-gray-600 mt-2"
|
||||
>{$t('connections.models')}</label
|
||||
>
|
||||
<p class="text-[10px] text-gray-300 dark:text-gray-700 mb-0.5">{$t('connections.modelsHint')}</p>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="claude-sonnet-4-20250514, claude-opus-4-20250514"
|
||||
|
||||
@@ -217,8 +217,11 @@
|
||||
"connections.baseUrl": "Base URL",
|
||||
"connections.prefixId": "Prefix ID",
|
||||
"connections.models": "Models (comma-separated, optional)",
|
||||
"connections.modelsHint": "Leave blank to auto-discover from provider.",
|
||||
"connections.cancel": "Cancel",
|
||||
"connections.add": "Add",
|
||||
"connections.edit": "Edit Connection",
|
||||
"connections.updated": "Connection updated",
|
||||
"connections.verify": "Verify",
|
||||
|
||||
"bar.newChat": "New Chat",
|
||||
|
||||
+23
-3
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
|
||||
@@ -14,6 +15,8 @@ from cptr.models import Chat, ChatMessage, Config
|
||||
from cptr.utils.config import check_access, now_ms, _get_jwt_secret
|
||||
from cptr.utils.crypto import decrypt_key
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/api/chats", tags=["chats"])
|
||||
|
||||
COOKIE_NAME = "cptr_session"
|
||||
@@ -228,7 +231,14 @@ async def _fetch_provider_models(conn: dict) -> list[str]:
|
||||
)
|
||||
if r.status_code == 200:
|
||||
data = r.json()
|
||||
return [m["id"] for m in data.get("data", [])]
|
||||
models = [m["id"] for m in data.get("data", [])]
|
||||
log.info("Auto-discovered %d models from %s", len(models), url)
|
||||
return models
|
||||
else:
|
||||
log.warning(
|
||||
"Model auto-discovery failed for %s: HTTP %d",
|
||||
url, r.status_code,
|
||||
)
|
||||
|
||||
elif provider == "openai":
|
||||
url = (base_url or "https://api.openai.com/v1") + "/models"
|
||||
@@ -241,10 +251,20 @@ async def _fetch_provider_models(conn: dict) -> list[str]:
|
||||
)
|
||||
if r.status_code == 200:
|
||||
data = r.json()
|
||||
return [m["id"] for m in data.get("data", [])]
|
||||
models = [m["id"] for m in data.get("data", [])]
|
||||
log.info("Auto-discovered %d models from %s", len(models), url)
|
||||
return models
|
||||
else:
|
||||
log.warning(
|
||||
"Model auto-discovery failed for %s: HTTP %d",
|
||||
url, r.status_code,
|
||||
)
|
||||
|
||||
else:
|
||||
log.warning("Unknown provider '%s', skipping model auto-discovery", provider)
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
log.exception("Model auto-discovery error for connection %s", conn.get("id", "?"))
|
||||
|
||||
return []
|
||||
|
||||
|
||||
Reference in new issue
Block a user