Add runtime provider controls and searchable AI routing
Manage provider keys at runtime, route current-information questions through server-side search with safe fallback, and scope OOBE usage claims to grants.
This commit is contained in:
@@ -14,6 +14,9 @@ import type {
|
||||
CreditGrantResponse,
|
||||
LedgerQuery,
|
||||
LedgerEntry,
|
||||
ManagedProviderId,
|
||||
ManagedProviderOverview,
|
||||
ManagedProviderStatus,
|
||||
OperatorsQuery,
|
||||
Overview,
|
||||
PageResult,
|
||||
@@ -30,6 +33,7 @@ import type {
|
||||
UpdateHintPackRequest,
|
||||
UpdateHintFeedSettingsRequest,
|
||||
UpdateOfficialSkillRequest,
|
||||
UpdateProviderApiKeyRequest,
|
||||
} from "./types";
|
||||
|
||||
const API_BASE = "/v1/admin";
|
||||
@@ -89,6 +93,8 @@ function safeMessage(status: number, code?: string): string {
|
||||
HINT_FEED_GENERATION_IN_PROGRESS: "Hint 提示包正在生成,请稍后刷新",
|
||||
HINT_FEED_SETTINGS_INVALID: "Hint 自动生成配置不符合要求",
|
||||
HINT_FEED_GENERATION_FAILED: "Hint 提示包生成失败,旧版本仍保持可用",
|
||||
PROVIDER_API_KEY_INVALID: "API Key 不符合要求",
|
||||
PROVIDER_NOT_FOUND: "不支持该 Provider",
|
||||
RATE_LIMITED: "操作过于频繁,请稍后再试",
|
||||
};
|
||||
if (code && messages[code]) return messages[code];
|
||||
@@ -285,6 +291,20 @@ export const adminApi = {
|
||||
headers: { "Idempotency-Key": payload.idempotencyKey },
|
||||
}),
|
||||
|
||||
providers: () => request<ManagedProviderOverview>("/providers"),
|
||||
|
||||
updateProviderApiKey: (
|
||||
providerId: ManagedProviderId,
|
||||
payload: UpdateProviderApiKeyRequest,
|
||||
) =>
|
||||
request<ManagedProviderStatus>(
|
||||
`/providers/${encodeURIComponent(providerId)}/api-key`,
|
||||
{
|
||||
method: "PUT",
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
),
|
||||
|
||||
auditLogs: (value?: string | AuditQuery) =>
|
||||
request<PageResult<AuditLogEntry>>(
|
||||
`/audit${encodeQuery(cursorQuery(value))}`,
|
||||
|
||||
Reference in New Issue
Block a user