- Profile-aware proxy: inject API key from profile-specific .env, route requests via X-Hermes-Profile header - Remove auth.json dependency: built-in providers use .env, custom providers use config.yaml - Add allProviders field to available-models response with all hardcoded provider catalogs - Add Models tab in Settings for editing provider API keys (built-in → .env, custom → config.yaml) - Add PUT /api/config/providers/:poolKey for updating provider credentials - ProviderFormModal uses backend allProviders for preset dropdown - Gateway log format support: parse both agent and gateway log formats - Add webui server.log to log viewer with log rotation at 3MB - Fix provider delete loading state and OAuth provider cleanup - Setup script: require Node.js 23+, auto-upgrade if version too low Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
102 lines
2.4 KiB
TypeScript
102 lines
2.4 KiB
TypeScript
import { request } from '../client'
|
|
|
|
export interface HealthResponse {
|
|
status: string
|
|
version?: string
|
|
webui_version?: string
|
|
webui_latest?: string
|
|
webui_update_available?: boolean
|
|
}
|
|
|
|
// Config-based model types
|
|
export interface ModelInfo {
|
|
id: string
|
|
label: string
|
|
}
|
|
|
|
export interface ModelGroup {
|
|
provider: string
|
|
models: ModelInfo[]
|
|
}
|
|
|
|
export interface ConfigModelsResponse {
|
|
default: string
|
|
groups: ModelGroup[]
|
|
}
|
|
|
|
export interface AvailableModelGroup {
|
|
provider: string // credential pool key (e.g. "zai", "custom:subrouter.ai")
|
|
label: string // display name (e.g. "zai", "subrouter.ai")
|
|
base_url: string
|
|
models: string[]
|
|
api_key: string
|
|
}
|
|
|
|
export interface AvailableModelsResponse {
|
|
default: string
|
|
default_provider: string
|
|
groups: AvailableModelGroup[]
|
|
allProviders: AvailableModelGroup[]
|
|
}
|
|
|
|
export interface CustomProvider {
|
|
name: string
|
|
base_url: string
|
|
api_key: string
|
|
model: string
|
|
providerKey?: string | null
|
|
}
|
|
|
|
export async function checkHealth(): Promise<HealthResponse> {
|
|
return request<HealthResponse>('/health')
|
|
}
|
|
|
|
export async function triggerUpdate(): Promise<{ success: boolean; message: string }> {
|
|
return request<{ success: boolean; message: string }>('/api/hermes/update', { method: 'POST' })
|
|
}
|
|
|
|
export async function fetchConfigModels(): Promise<ConfigModelsResponse> {
|
|
return request<ConfigModelsResponse>('/api/hermes/config/models')
|
|
}
|
|
|
|
export async function fetchAvailableModels(): Promise<AvailableModelsResponse> {
|
|
return request<AvailableModelsResponse>('/api/hermes/available-models')
|
|
}
|
|
|
|
export async function updateDefaultModel(data: {
|
|
default: string
|
|
provider?: string
|
|
base_url?: string
|
|
api_key?: string
|
|
}): Promise<void> {
|
|
await request('/api/hermes/config/model', {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data),
|
|
})
|
|
}
|
|
|
|
export async function addCustomProvider(data: CustomProvider): Promise<void> {
|
|
await request('/api/hermes/config/providers', {
|
|
method: 'POST',
|
|
body: JSON.stringify(data),
|
|
})
|
|
}
|
|
|
|
export async function removeCustomProvider(name: string): Promise<void> {
|
|
await request(`/api/hermes/config/providers/${encodeURIComponent(name)}`, {
|
|
method: 'DELETE',
|
|
})
|
|
}
|
|
|
|
export async function updateProvider(poolKey: string, data: {
|
|
name?: string
|
|
base_url?: string
|
|
api_key?: string
|
|
model?: string
|
|
}): Promise<void> {
|
|
await request(`/api/hermes/config/providers/${encodeURIComponent(poolKey)}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data),
|
|
})
|
|
}
|