feat: complete TASK-WP3-01 model configuration
This commit is contained in:
@@ -190,6 +190,66 @@ export async function getGeneration(options: ClientOptions = {}): Promise<Genera
|
||||
return response.json() as Promise<GenerationTaskResponse>;
|
||||
}
|
||||
|
||||
export async function getModel(options: ClientOptions = {}): Promise<{
|
||||
"config_version": number;
|
||||
"contract_evidence_ref": string | null;
|
||||
"contract_validation_status": ModelContractValidationStatus;
|
||||
"credit_cost": number;
|
||||
"display_name": string;
|
||||
"enabled": boolean;
|
||||
"error_mapping_profile": Record<string, never>;
|
||||
"gateway_account_ref": string;
|
||||
"is_default": boolean;
|
||||
"model_id": ModelId;
|
||||
"prompt_max_length": number;
|
||||
"recommendation_priority": number;
|
||||
"reference_limits": ModelReferenceLimits;
|
||||
"route_profile": Record<string, never>;
|
||||
"runtime_availability": ModelRuntimeAvailability;
|
||||
"safety_source": string;
|
||||
"supported_ratios": Array<string>;
|
||||
}> {
|
||||
const request = options.fetch ?? globalThis.fetch;
|
||||
const response = await request(`${options.baseUrl ?? ""}/api/v1/models/{model_id}`, { method: "GET", headers: options.headers ?? {} });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
return response.json() as Promise<{
|
||||
"config_version": number;
|
||||
"contract_evidence_ref": string | null;
|
||||
"contract_validation_status": ModelContractValidationStatus;
|
||||
"credit_cost": number;
|
||||
"display_name": string;
|
||||
"enabled": boolean;
|
||||
"error_mapping_profile": Record<string, never>;
|
||||
"gateway_account_ref": string;
|
||||
"is_default": boolean;
|
||||
"model_id": ModelId;
|
||||
"prompt_max_length": number;
|
||||
"recommendation_priority": number;
|
||||
"reference_limits": ModelReferenceLimits;
|
||||
"route_profile": Record<string, never>;
|
||||
"runtime_availability": ModelRuntimeAvailability;
|
||||
"safety_source": string;
|
||||
"supported_ratios": Array<string>;
|
||||
}>;
|
||||
}
|
||||
|
||||
export async function getModels(options: ClientOptions = {}): Promise<{
|
||||
"config_set_version": number;
|
||||
"configured_default_model_id": ModelId;
|
||||
"models": Array<ModelConfig>;
|
||||
"recommended_model_id": ModelId | null;
|
||||
}> {
|
||||
const request = options.fetch ?? globalThis.fetch;
|
||||
const response = await request(`${options.baseUrl ?? ""}/api/v1/models`, { method: "GET", headers: options.headers ?? {} });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
return response.json() as Promise<{
|
||||
"config_set_version": number;
|
||||
"configured_default_model_id": ModelId;
|
||||
"models": Array<ModelConfig>;
|
||||
"recommended_model_id": ModelId | null;
|
||||
}>;
|
||||
}
|
||||
|
||||
export async function getMyCreditLedger(options: ClientOptions = {}): Promise<CreditLedgerResponse> {
|
||||
const request = options.fetch ?? globalThis.fetch;
|
||||
const response = await request(`${options.baseUrl ?? ""}/api/v1/me/credit-ledger`, { method: "GET", headers: options.headers ?? {} });
|
||||
@@ -248,6 +308,28 @@ export async function renameProject(body: ProjectRenameRequest, options: ClientO
|
||||
return response.json() as Promise<ProjectRenameResponse>;
|
||||
}
|
||||
|
||||
export async function replaceModelConfiguration(body: {
|
||||
"expected_config_set_version": number;
|
||||
"models": Array<ModelConfigCandidate>;
|
||||
}, options: ClientOptions = {}): Promise<{
|
||||
"config_set_version": number;
|
||||
"configured_default_model_id": ModelId;
|
||||
"models": Array<ModelConfig>;
|
||||
"recommended_model_id": ModelId | null;
|
||||
}> {
|
||||
const request = options.fetch ?? globalThis.fetch;
|
||||
const headers = new Headers(options.headers);
|
||||
headers.set("Content-Type", "application/json");
|
||||
const response = await request(`${options.baseUrl ?? ""}/api/v1/admin/models/configuration`, { body: JSON.stringify(body), method: "PUT", headers });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
return response.json() as Promise<{
|
||||
"config_set_version": number;
|
||||
"configured_default_model_id": ModelId;
|
||||
"models": Array<ModelConfig>;
|
||||
"recommended_model_id": ModelId | null;
|
||||
}>;
|
||||
}
|
||||
|
||||
export async function restoreProject(options: ClientOptions = {}): Promise<ProjectRestoreResponse> {
|
||||
const request = options.fetch ?? globalThis.fetch;
|
||||
const response = await request(`${options.baseUrl ?? ""}/api/v1/projects/{projectId}/restore`, { method: "POST", headers: options.headers ?? {} });
|
||||
|
||||
@@ -273,6 +273,7 @@ export type CsrfHeaders = {
|
||||
|
||||
export type ErrorDetails = {
|
||||
"capacity_status"?: "normal" | "warning" | "critical" | "full" | "unavailable";
|
||||
"conflict_model_ids"?: Array<string>;
|
||||
"current_task_ref"?: string;
|
||||
"field_errors"?: Array<{
|
||||
"field": string;
|
||||
@@ -293,6 +294,7 @@ export type ErrorEnvelope = {
|
||||
"correlation_id": string;
|
||||
"details": {
|
||||
"capacity_status"?: "normal" | "warning" | "critical" | "full" | "unavailable";
|
||||
"conflict_model_ids"?: Array<string>;
|
||||
"current_task_ref"?: string;
|
||||
"field_errors"?: Array<{
|
||||
"field": string;
|
||||
@@ -448,6 +450,42 @@ export type LogoutResponse = {
|
||||
"status": "logged_out";
|
||||
};
|
||||
|
||||
export type ModelConfig = {
|
||||
"config_version": number;
|
||||
"contract_evidence_ref": string | null;
|
||||
"contract_validation_status": ModelContractValidationStatus;
|
||||
"credit_cost": number;
|
||||
"display_name": string;
|
||||
"enabled": boolean;
|
||||
"error_mapping_profile": Record<string, never>;
|
||||
"gateway_account_ref": string;
|
||||
"is_default": boolean;
|
||||
"model_id": ModelId;
|
||||
"prompt_max_length": number;
|
||||
"recommendation_priority": number;
|
||||
"reference_limits": ModelReferenceLimits;
|
||||
"route_profile": Record<string, never>;
|
||||
"runtime_availability": ModelRuntimeAvailability;
|
||||
"safety_source": string;
|
||||
"supported_ratios": Array<string>;
|
||||
};
|
||||
|
||||
export type ModelConfigCandidate = {
|
||||
"credit_cost": number;
|
||||
"display_name": string;
|
||||
"enabled": boolean;
|
||||
"error_mapping_profile": Record<string, never>;
|
||||
"gateway_account_ref": string;
|
||||
"is_default": boolean;
|
||||
"model_id": ModelId;
|
||||
"prompt_max_length": number;
|
||||
"recommendation_priority": number;
|
||||
"reference_limits": ModelReferenceLimits;
|
||||
"route_profile": Record<string, never>;
|
||||
"safety_source": string;
|
||||
"supported_ratios": Array<string>;
|
||||
};
|
||||
|
||||
export type ModelConfigSseEvent = {
|
||||
"config_set_version": number;
|
||||
"entity_ref": string;
|
||||
@@ -456,6 +494,45 @@ export type ModelConfigSseEvent = {
|
||||
"occurred_at": string;
|
||||
};
|
||||
|
||||
export type ModelConfigUpdateHeaders = {
|
||||
"idempotency-key": string;
|
||||
"x-csrf-token": string;
|
||||
};
|
||||
|
||||
export type ModelConfigUpdateRequest = {
|
||||
"expected_config_set_version": number;
|
||||
"models": Array<ModelConfigCandidate>;
|
||||
};
|
||||
|
||||
export type ModelConfigurationResponse = {
|
||||
"config_set_version": number;
|
||||
"configured_default_model_id": ModelId;
|
||||
"models": Array<ModelConfig>;
|
||||
"recommended_model_id": ModelId | null;
|
||||
};
|
||||
|
||||
export type ModelContractValidationStatus = "blocked" | "unverified" | "verified";
|
||||
|
||||
export type ModelId = string;
|
||||
|
||||
export type ModelParams = {
|
||||
"model_id": ModelId;
|
||||
};
|
||||
|
||||
export type ModelReferenceLimits = {
|
||||
"max_file_bytes": number;
|
||||
"max_files": number;
|
||||
"max_total_bytes": number;
|
||||
};
|
||||
|
||||
export type ModelRuntimeAvailability = {
|
||||
"available_for_new_jobs": boolean;
|
||||
"checked_at": string;
|
||||
"reason": ModelRuntimeReason;
|
||||
};
|
||||
|
||||
export type ModelRuntimeReason = "available" | "configured_disabled" | "contract_unverified" | "contract_blocked" | "gateway_balance_insufficient" | "gateway_paused" | "worker_degraded";
|
||||
|
||||
export type ModelRuntimeSseEvent = {
|
||||
"entity_ref": string;
|
||||
"event_id": number;
|
||||
|
||||
Reference in New Issue
Block a user