mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 19:29:50 +08:00
feat(vertex-ai): 重构 Vertex AI 为插件化 adapter,支持 service_account 认证与动态路由
将 Vertex AI 从 transport.py 的硬编码逻辑重构为独立的 plugin adapter, 支持 service_account/oauth 认证类型、模型格式自动识别、区域路由和 URL 构建。 前端新增 Key 认证类型选择和 Service Account 配置表单。 Co-authored-by: NyaDoo <[email protected]> Closes #194
This commit is contained in:
@@ -224,7 +224,7 @@
|
||||
<div class="p-4 border-b border-border/60">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-sm font-semibold">
|
||||
{{ provider.provider_type === 'custom' ? '密钥管理' : '账号管理' }}
|
||||
{{ isKeyManagedProviderType(provider.provider_type) ? '密钥管理' : '账号管理' }}
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<Button
|
||||
@@ -235,7 +235,7 @@
|
||||
@click="handleAddKeyToFirstEndpoint"
|
||||
>
|
||||
<Plus class="w-3.5 h-3.5 mr-1.5" />
|
||||
{{ provider.provider_type === 'custom' ? '添加密钥' : '添加账号' }}
|
||||
{{ isKeyManagedProviderType(provider.provider_type) ? '添加密钥' : '添加账号' }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -301,7 +301,7 @@
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<span class="text-[11px] font-mono text-muted-foreground">
|
||||
{{ key.auth_type === 'oauth' ? '[Refresh Token]' : (key.auth_type === 'vertex_ai' ? 'Vertex AI' : key.api_key_masked) }}
|
||||
{{ key.auth_type === 'oauth' ? '[Refresh Token]' : (key.auth_type === 'service_account' ? '[Service Account]' : key.api_key_masked) }}
|
||||
</span>
|
||||
<Button
|
||||
v-if="key.auth_type === 'oauth'"
|
||||
@@ -844,7 +844,7 @@
|
||||
v-if="shouldPaginateKeys"
|
||||
class="px-4 py-2 flex items-center justify-between text-xs text-muted-foreground mt-auto"
|
||||
>
|
||||
<span>共 {{ allKeys.length }} 个{{ provider.provider_type === 'custom' ? '密钥' : '账号' }}</span>
|
||||
<span>共 {{ allKeys.length }} 个{{ isKeyManagedProviderType(provider.provider_type) ? '密钥' : '账号' }}</span>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -876,11 +876,11 @@
|
||||
>
|
||||
<Key class="w-12 h-12 mx-auto mb-3 opacity-50" />
|
||||
<p class="text-sm">
|
||||
{{ provider.provider_type === 'custom' ? '暂无密钥配置' : '暂无账号配置' }}
|
||||
{{ isKeyManagedProviderType(provider.provider_type) ? '暂无密钥配置' : '暂无账号配置' }}
|
||||
</p>
|
||||
<p class="text-xs mt-1">
|
||||
{{ endpoints.length > 0
|
||||
? (provider.provider_type === 'custom' ? '点击上方"添加密钥"按钮创建第一个密钥' : '点击上方"添加账号"按钮添加第一个账号')
|
||||
? (isKeyManagedProviderType(provider.provider_type) ? '点击上方"添加密钥"按钮创建第一个密钥' : '点击上方"添加账号"按钮添加第一个账号')
|
||||
: '请先添加端点,然后再添加密钥' }}
|
||||
</p>
|
||||
</div>
|
||||
@@ -1100,6 +1100,7 @@ import {
|
||||
} from '@/api/endpoints'
|
||||
import type { UpstreamMetadata, AntigravityModelQuota } from '@/api/endpoints/types'
|
||||
import { formatApiFormat } from '@/api/endpoints/types/api-format'
|
||||
import { isOAuthAccountProviderType, isKeyManagedProviderType } from '../utils/providerTypeUtils'
|
||||
|
||||
// 扩展端点类型,包含密钥列表
|
||||
interface ProviderEndpointWithKeys extends ProviderEndpoint {
|
||||
@@ -1417,11 +1418,11 @@ function handleAddKey(endpoint: ProviderEndpoint) {
|
||||
function handleAddKeyToFirstEndpoint() {
|
||||
if (endpoints.value.length === 0) return
|
||||
|
||||
// 非自定义提供商:打开 OAuth 账号对话框
|
||||
if (provider.value?.provider_type !== 'custom') {
|
||||
// OAuth 账号型提供商:打开 OAuth 账号对话框
|
||||
if (isOAuthAccountProviderType(provider.value?.provider_type)) {
|
||||
oauthAccountDialogOpen.value = true
|
||||
} else {
|
||||
// 自定义提供商:打开密钥表单对话框
|
||||
// 密钥型提供商(custom/vertex_ai):打开密钥表单对话框
|
||||
handleAddKey(endpoints.value[0])
|
||||
}
|
||||
}
|
||||
@@ -1455,8 +1456,8 @@ async function copyFullKey(key: EndpointAPIKey) {
|
||||
const result = await revealEndpointKey(key.id)
|
||||
let textToCopy: string
|
||||
|
||||
if (result.auth_type === 'vertex_ai' && result.auth_config) {
|
||||
// Vertex AI 类型:复制 auth_config JSON
|
||||
if (result.auth_type === 'service_account' && result.auth_config) {
|
||||
// Service Account 类型:复制 auth_config JSON
|
||||
textToCopy = typeof result.auth_config === 'string'
|
||||
? result.auth_config
|
||||
: JSON.stringify(result.auth_config, null, 2)
|
||||
|
||||
Reference in New Issue
Block a user