feat(cloud): manage LLM providers in database
Tests / Test passed: 664

This commit is contained in:
2026-07-14 00:31:47 +08:00
parent b613a315ff
commit a166ffd8a4
35 changed files with 2432 additions and 204 deletions
+64
View File
@@ -3,6 +3,10 @@ import type {
DeviceRecord,
HostGovernancePolicy,
HostTokenUsageSummary,
LlmProviderProfile,
LlmProviderProfileListResponse,
LlmProviderSettings,
LlmProviderType,
HostRecord,
PluginRecord,
PluginRegistrationPayload,
@@ -253,3 +257,63 @@ export function registerPlugin(payload: PluginRegistrationPayload): Promise<Plug
body: JSON.stringify(payload),
});
}
export function listLlmProviderProfiles(): Promise<LlmProviderProfileListResponse> {
return request<LlmProviderProfileListResponse>("/v1/planner/providers");
}
export function createLlmProviderProfile(payload: {
name: string;
provider_type: LlmProviderType;
model: string;
base_url?: string | null;
timeout_seconds: number;
api_key: string;
}): Promise<LlmProviderProfile> {
return request<LlmProviderProfile>("/v1/planner/providers", {
method: "POST",
body: JSON.stringify(payload),
});
}
export function updateLlmProviderProfile(
profileId: string,
payload: {
name?: string;
provider_type?: LlmProviderType;
model?: string;
base_url?: string | null;
timeout_seconds?: number;
enabled?: boolean;
api_key?: string;
expected_revision?: number;
},
): Promise<LlmProviderProfile> {
return request<LlmProviderProfile>(`/v1/planner/providers/${encodeURIComponent(profileId)}`, {
method: "PATCH",
body: JSON.stringify(payload),
});
}
export function activateLlmProviderProfile(
profileId: string,
expectedSettingsRevision: number,
): Promise<LlmProviderSettings> {
return request<LlmProviderSettings>(
`/v1/planner/providers/${encodeURIComponent(profileId)}/activate`,
{
method: "POST",
body: JSON.stringify({ expected_settings_revision: expectedSettingsRevision }),
},
);
}
export function deleteLlmProviderProfile(
profileId: string,
expectedRevision: number,
): Promise<void> {
return request<void>(
`/v1/planner/providers/${encodeURIComponent(profileId)}?expected_revision=${expectedRevision}`,
{ method: "DELETE" },
);
}