Persist custom Hermes models (#913)

This commit is contained in:
ekko
2026-05-21 20:55:19 +08:00
committed by GitHub
parent 4d89767847
commit ff1f471745
9 changed files with 418 additions and 13 deletions
+24
View File
@@ -31,6 +31,7 @@ export interface ModelVisibilityRule {
}
export type ModelVisibility = Record<string, ModelVisibilityRule>
export type CustomModels = Record<string, string[]>
export interface AvailableModelGroup {
provider: string // credential pool key (e.g. "zai", "custom:subrouter.ai")
@@ -61,6 +62,7 @@ export interface AvailableModelsResponse {
/** Web UI-only display aliases keyed by provider -> canonical model ID. */
model_aliases?: Record<string, Record<string, string>>
model_visibility?: ModelVisibility
custom_models?: CustomModels
}
export interface CustomProvider {
@@ -163,3 +165,25 @@ export async function updateModelVisibility(data: {
body: JSON.stringify(data),
})
}
export async function addCustomModel(data: {
provider: string
model: string
}): Promise<{ success: boolean; custom_models: CustomModels }> {
return request<{ success: boolean; custom_models: CustomModels }>('/api/hermes/custom-model', {
method: 'PUT',
body: JSON.stringify(data),
})
}
export async function removeCustomModel(data: {
provider: string
model: string
}): Promise<{ success: boolean; custom_models: CustomModels }> {
const params = new URLSearchParams()
params.set('provider', data.provider)
params.set('model', data.model)
return request<{ success: boolean; custom_models: CustomModels }>(`/api/hermes/custom-model?${params.toString()}`, {
method: 'DELETE',
})
}