mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
refactor: 优化提供商管理界面交互与术语,增强 OAuth 编辑体验
- 模型映射对话框统一术语为"客户端模型/提供商模型",修复编辑时已有映射不可见的问题 - 密钥表单包含/排除规则改为双列布局 - OAuth 密钥编辑对话框增加 dirty 状态跟踪,关闭时提示未保存更改 - 调整密钥操作按钮顺序,代理节点配置移至编辑按钮前 - preset_models.py 添加 ModelsFetcherFunc 类型别名
This commit is contained in:
@@ -10,8 +10,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import Any
|
||||
|
||||
# Fetcher 函数签名:与 UpstreamModelsFetcherRegistry 中的 _ModelsFetcher 保持一致
|
||||
# (ctx, timeout_seconds) -> (models, errors, has_success, upstream_metadata)
|
||||
ModelsFetcherFunc = Callable[
|
||||
[Any, float],
|
||||
Awaitable[tuple[list[dict], list[str], bool, dict[str, Any] | None]],
|
||||
]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 预设模型定义
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -124,7 +132,7 @@ def get_preset_models(provider_type: str) -> list[dict[str, Any]]:
|
||||
|
||||
def create_preset_models_fetcher(
|
||||
provider_type: str,
|
||||
) -> Any:
|
||||
) -> ModelsFetcherFunc:
|
||||
"""创建一个返回预设模型列表的 fetcher 函数。
|
||||
|
||||
Args:
|
||||
@@ -136,22 +144,21 @@ def create_preset_models_fetcher(
|
||||
models = get_preset_models(provider_type)
|
||||
|
||||
async def fetch_preset_models(
|
||||
ctx: Any,
|
||||
timeout_seconds: float, # noqa: ARG001
|
||||
_ctx: Any,
|
||||
_timeout_seconds: float,
|
||||
) -> tuple[list[dict], list[str], bool, dict[str, Any] | None]:
|
||||
"""Return preset model catalog.
|
||||
|
||||
This provider does not expose a /v1/models endpoint, so we skip the
|
||||
HTTP call entirely and return a hardcoded list.
|
||||
"""
|
||||
_ = ctx
|
||||
_ = timeout_seconds
|
||||
return list(models), [], True, None
|
||||
|
||||
return fetch_preset_models
|
||||
|
||||
|
||||
__all__ = [
|
||||
"ModelsFetcherFunc",
|
||||
"PRESET_MODELS",
|
||||
"create_preset_models_fetcher",
|
||||
"get_preset_models",
|
||||
|
||||
Reference in New Issue
Block a user