mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 01:40:21 +08:00
Merge remote-tracking branch 'origin/pr/451' into aether-rust-pioneer
This commit is contained in:
@@ -4,10 +4,14 @@ import type {
|
||||
ClaudeCodeAdvancedConfig,
|
||||
FailoverRulesConfig,
|
||||
PoolAdvancedConfig,
|
||||
ProviderConfig,
|
||||
ProviderWithEndpointsSummary,
|
||||
ProxyConfig,
|
||||
} from './types'
|
||||
import { normalizePoolAdvancedConfig as normalizePoolAdvanced } from './types'
|
||||
import {
|
||||
normalizeChatPiiRedactionProviderConfig as normalizeChatPiiRedactionProvider,
|
||||
normalizePoolAdvancedConfig as normalizePoolAdvanced,
|
||||
} from './types'
|
||||
|
||||
interface ProviderRequestOptions {
|
||||
timeout?: number
|
||||
@@ -42,6 +46,7 @@ function normalizeProviderSummary(
|
||||
): ProviderWithEndpointsSummary {
|
||||
return {
|
||||
...provider,
|
||||
chat_pii_redaction: normalizeChatPiiRedactionProvider(provider.chat_pii_redaction),
|
||||
pool_advanced: normalizePoolAdvanced(provider.pool_advanced),
|
||||
}
|
||||
}
|
||||
@@ -107,6 +112,7 @@ export async function updateProvider(
|
||||
claude_code_advanced: ClaudeCodeAdvancedConfig | null
|
||||
pool_advanced: PoolAdvancedConfig | null
|
||||
failover_rules: FailoverRulesConfig | null
|
||||
config: ProviderConfig | null
|
||||
}>,
|
||||
requestOptions?: ProviderRequestOptions,
|
||||
): Promise<ProviderWithEndpointsSummary> {
|
||||
@@ -138,6 +144,7 @@ export async function createProvider(
|
||||
claude_code_advanced?: ClaudeCodeAdvancedConfig | null
|
||||
pool_advanced?: PoolAdvancedConfig | null
|
||||
failover_rules?: FailoverRulesConfig | null
|
||||
config?: ProviderConfig | null
|
||||
}
|
||||
): Promise<{ id: string; name: string; message?: string }> {
|
||||
const response = await client.post('/api/admin/providers/', data)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { normalizePoolAdvancedConfig } from '@/api/endpoints/types'
|
||||
import { normalizeChatPiiRedactionProviderConfig, normalizePoolAdvancedConfig } from '@/api/endpoints/types'
|
||||
|
||||
describe('normalizePoolAdvancedConfig', () => {
|
||||
it('keeps object payloads, including empty objects', () => {
|
||||
@@ -19,3 +19,17 @@ describe('normalizePoolAdvancedConfig', () => {
|
||||
expect(normalizePoolAdvancedConfig(['lru'])).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('normalizeChatPiiRedactionProviderConfig', () => {
|
||||
it('defaults unsupported payloads to disabled', () => {
|
||||
expect(normalizeChatPiiRedactionProviderConfig(null)).toEqual({ enabled: false })
|
||||
expect(normalizeChatPiiRedactionProviderConfig({})).toEqual({ enabled: false })
|
||||
expect(normalizeChatPiiRedactionProviderConfig({ enabled: 'yes' })).toEqual({ enabled: false })
|
||||
})
|
||||
|
||||
it('passes through enabled state only', () => {
|
||||
expect(normalizeChatPiiRedactionProviderConfig({ enabled: true })).toEqual({ enabled: true })
|
||||
expect(normalizeChatPiiRedactionProviderConfig({ enabled: false, entities: ['email'] })).toEqual({ enabled: false })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -176,6 +176,18 @@ export interface FormatAcceptanceConfig {
|
||||
reject_formats?: string[] // 黑名单:拒绝哪些格式(优先级高于白名单)
|
||||
}
|
||||
|
||||
export interface ChatPiiRedactionProviderConfig {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export interface ProviderConfig {
|
||||
chat_pii_redaction?: ChatPiiRedactionProviderConfig
|
||||
pool_advanced?: PoolAdvancedConfig
|
||||
failover_rules?: FailoverRulesConfig
|
||||
claude_code_advanced?: ClaudeCodeAdvancedConfig
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface ProviderEndpoint {
|
||||
id: string
|
||||
provider_id: string
|
||||
@@ -579,6 +591,13 @@ function isPlainObject(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
export function normalizeChatPiiRedactionProviderConfig(value: unknown): ChatPiiRedactionProviderConfig {
|
||||
if (!isPlainObject(value) || typeof value.enabled !== 'boolean') {
|
||||
return { enabled: false }
|
||||
}
|
||||
return { enabled: value.enabled }
|
||||
}
|
||||
|
||||
export function normalizePoolAdvancedConfig(value: unknown): PoolAdvancedConfig | null {
|
||||
if (value == null || value === false) return null
|
||||
if (value === true) return {}
|
||||
@@ -631,6 +650,7 @@ export interface ProviderWithEndpointsSummary {
|
||||
api_formats: string[]
|
||||
endpoint_health_details: EndpointHealthDetail[]
|
||||
claude_code_advanced?: ClaudeCodeAdvancedConfig | null
|
||||
chat_pii_redaction?: ChatPiiRedactionProviderConfig | null
|
||||
pool_advanced?: PoolAdvancedConfig | null
|
||||
failover_rules?: FailoverRulesConfig | null
|
||||
ops_configured: boolean // 是否配置了扩展操作(余额监控等)
|
||||
|
||||
Reference in New Issue
Block a user