Independent React, TypeScript and Vite web application for MaskanX. Includes the chat console, agent and persona configuration, MCP client management, model and provider settings, cron jobs, sessions, and diagnostics. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
100 lines
2.7 KiB
TypeScript
100 lines
2.7 KiB
TypeScript
import { request } from "../request";
|
|
import type {
|
|
ProviderInfo,
|
|
ProviderConfigRequest,
|
|
ActiveModelsInfo,
|
|
ProviderUsageInfo,
|
|
ModelSlotRequest,
|
|
CreateCustomProviderRequest,
|
|
AddModelRequest,
|
|
TestConnectionResponse,
|
|
TestModelRequest,
|
|
FallbackConfig,
|
|
} from "../types";
|
|
|
|
export const providerApi = {
|
|
listProviders: () => request<ProviderInfo[]>("/models"),
|
|
|
|
configureProvider: (providerId: string, body: ProviderConfigRequest) =>
|
|
request<ProviderInfo>(`/models/${encodeURIComponent(providerId)}/config`, {
|
|
method: "PUT",
|
|
body: JSON.stringify(body),
|
|
}),
|
|
|
|
getActiveModels: () => request<ActiveModelsInfo>("/models/active"),
|
|
|
|
setActiveLlm: (body: ModelSlotRequest) =>
|
|
request<ActiveModelsInfo>("/models/active", {
|
|
method: "PUT",
|
|
body: JSON.stringify(body),
|
|
}),
|
|
|
|
getProviderUsage: (providerId: string) =>
|
|
request<ProviderUsageInfo>(
|
|
`/models/${encodeURIComponent(providerId)}/usage`,
|
|
),
|
|
|
|
/* ---- Custom provider CRUD ---- */
|
|
|
|
createCustomProvider: (body: CreateCustomProviderRequest) =>
|
|
request<ProviderInfo>("/models/custom-providers", {
|
|
method: "POST",
|
|
body: JSON.stringify(body),
|
|
}),
|
|
|
|
deleteCustomProvider: (providerId: string) =>
|
|
request<ProviderInfo[]>(
|
|
`/models/custom-providers/${encodeURIComponent(providerId)}`,
|
|
{ method: "DELETE" },
|
|
),
|
|
|
|
/* ---- Model CRUD (works for both built-in and custom providers) ---- */
|
|
|
|
addModel: (providerId: string, body: AddModelRequest) =>
|
|
request<ProviderInfo>(`/models/${encodeURIComponent(providerId)}/models`, {
|
|
method: "POST",
|
|
body: JSON.stringify(body),
|
|
}),
|
|
|
|
removeModel: (providerId: string, modelId: string) =>
|
|
request<ProviderInfo>(
|
|
`/models/${encodeURIComponent(providerId)}/models/${encodeURIComponent(
|
|
modelId,
|
|
)}`,
|
|
{ method: "DELETE" },
|
|
),
|
|
|
|
/* ---- Test Connection ---- */
|
|
|
|
testProviderConnection: (
|
|
providerId: string,
|
|
body?: { api_key?: string; base_url?: string },
|
|
) =>
|
|
request<TestConnectionResponse>(
|
|
`/models/${encodeURIComponent(providerId)}/test`,
|
|
{
|
|
method: "POST",
|
|
body: body ? JSON.stringify(body) : undefined,
|
|
},
|
|
),
|
|
|
|
testModelConnection: (providerId: string, body: TestModelRequest) =>
|
|
request<TestConnectionResponse>(
|
|
`/models/${encodeURIComponent(providerId)}/models/test`,
|
|
{
|
|
method: "POST",
|
|
body: JSON.stringify(body),
|
|
},
|
|
),
|
|
|
|
/* ---- Fallback chain ---- */
|
|
|
|
getFallbackConfig: () => request<FallbackConfig>("/models/fallback"),
|
|
|
|
setFallbackConfig: (body: FallbackConfig) =>
|
|
request<FallbackConfig>("/models/fallback", {
|
|
method: "PUT",
|
|
body: JSON.stringify(body),
|
|
}),
|
|
};
|