mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-12 12:09:50 +08:00
feat(provider): 重构模型测试对话框,加固 Vertex AI 传输层
模型测试: - 将消息输入替换为完整 JSON 请求体编辑器,支持格式化和校验 - 新增端点选择面板,测试前可选择目标端点 - 新增调试检查器,可查看每次尝试的请求/响应头和体 - 结果视图改用 HorizontalRequestTimeline 组件展示请求追踪 - endpoint_checker 返回完整调试数据,通过 candidate extra_data 持久化 Vertex AI: - 改进上下文检测逻辑,不再仅依赖 provider_type,支持从 base_url 推断 - Service Account 密钥现支持自动拉取模型(使用 auth_config 而非 api_key) - 移除 Gemini Developer API 回退,API Key 仅走 Express 模式 - 端点表单为 Vertex AI 显示格式特定的默认路径模板 - 密钥格式校验仅在 auth_type/api_formats 变更时执行 其他: - 禁用 ClaudeCode 提供商类型创建入口 - Dialog 组件新增 closeOnBackdrop 属性
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
from dataclasses import dataclass
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from src.services.provider.transport import build_provider_url
|
||||
|
||||
@@ -61,3 +64,52 @@ def test_gemini_non_stream_does_not_add_alt() -> None:
|
||||
|
||||
assert url.endswith("/v1beta/models/gemini-1.5-pro:generateContent")
|
||||
assert "alt=" not in url
|
||||
|
||||
|
||||
def test_vertex_gemini_api_key_base_url_uses_vertex_transport_without_provider_type(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
endpoint = _DummyEndpoint(
|
||||
base_url="https://aiplatform.googleapis.com",
|
||||
api_format="gemini:chat",
|
||||
)
|
||||
key = SimpleNamespace(auth_type="api_key", api_key="enc-key")
|
||||
|
||||
from src.core.crypto import crypto_service
|
||||
|
||||
monkeypatch.setattr(crypto_service, "decrypt", lambda value: "test-key")
|
||||
|
||||
url = build_provider_url(
|
||||
endpoint, # type: ignore[arg-type] - test stub
|
||||
path_params={"model": "gemini-3.1-pro-preview"},
|
||||
is_stream=False,
|
||||
key=key, # type: ignore[arg-type] - test stub
|
||||
)
|
||||
|
||||
assert (
|
||||
url == "https://aiplatform.googleapis.com/v1/publishers/google/models/"
|
||||
"gemini-3.1-pro-preview:generateContent?key=test-key"
|
||||
)
|
||||
|
||||
|
||||
def test_vertex_gemini_service_account_base_url_uses_vertex_transport_without_provider_type() -> (
|
||||
None
|
||||
):
|
||||
endpoint = _DummyEndpoint(
|
||||
base_url="https://aiplatform.googleapis.com",
|
||||
api_format="gemini:chat",
|
||||
)
|
||||
key = SimpleNamespace(auth_type="service_account", auth_config={"project_id": "demo-project"})
|
||||
|
||||
url = build_provider_url(
|
||||
endpoint, # type: ignore[arg-type] - test stub
|
||||
path_params={"model": "gemini-3.1-pro-preview"},
|
||||
is_stream=False,
|
||||
key=key, # type: ignore[arg-type] - test stub
|
||||
decrypted_auth_config={"project_id": "demo-project", "region": "global"},
|
||||
)
|
||||
|
||||
assert (
|
||||
url == "https://aiplatform.googleapis.com/v1/projects/demo-project/locations/global/"
|
||||
"publishers/google/models/gemini-3.1-pro-preview:generateContent"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user