import {z} from 'zod' export type GetApiV1AccountsAccountIdTrainingShapesTrainingShapeIdArgs = {readMask?: string | undefined, account_id: string, training_shape_id: string}; export type GetApiV1AccountsAccountIdTrainingShapesTrainingShapeIdOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const trainingShapeTrainerMode = z.enum(["TRAINER_MODE_UNSPECIFIED", "POLICY_TRAINER", "FORWARD_ONLY", "LORA_TRAINER"]); export const gatewayTrainerShardingScheme = z.object({tensorParallelism: z.number().int().optional(), pipelineParallelism: z.number().int().optional(), contextParallelism: z.number().int().optional(), expertParallelism: z.number().int().optional(), sequenceParallelism: z.boolean().optional()}); export const gatewayAcceleratorType = z.enum(["ACCELERATOR_TYPE_UNSPECIFIED", "NVIDIA_A100_80GB", "NVIDIA_H100_80GB", "AMD_MI300X_192GB", "NVIDIA_A10G_24GB", "NVIDIA_A100_40GB", "NVIDIA_L4_24GB", "NVIDIA_H200_141GB", "NVIDIA_B200_180GB", "AMD_MI325X_256GB", "AMD_MI350X_288GB", "NVIDIA_B300_288GB", "NVIDIA_GB200", "NVIDIA_GB300"]); export const gatewayWeightPrecision = z.enum(["WEIGHT_PRECISION_UNSPECIFIED", "BFLOAT16", "INT8", "NF4", "FP8", "FP4_FP8"]); export const gatewayTrainingShape = z.object({name: z.string().optional(), displayName: z.string().optional(), description: z.string().optional(), createTime: z.string().optional(), updateTime: z.string().optional(), baseModel: z.string(), deploymentShapeVersion: z.string().optional(), trainerImageTag: z.string(), trainerMode: trainingShapeTrainerMode.optional(), nodeCount: z.number().int().optional(), trainerShardingScheme: gatewayTrainerShardingScheme.optional(), modelType: z.string().optional(), parameterCount: z.string().optional(), acceleratorType: gatewayAcceleratorType.optional(), acceleratorCount: z.number().int().optional(), baseModelWeightPrecision: gatewayWeightPrecision.optional(), maxSupportedContextLength: z.number().int().optional(), minTotalAcceleratorCount: z.number().int().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Get Training Shape * * GET /v1/accounts/{account_id}/trainingShapes/{training_shape_id} */ export const getApiV1AccountsAccountIdTrainingShapesTrainingShapeId = async (args: GetApiV1AccountsAccountIdTrainingShapesTrainingShapeIdArgs, options: GetApiV1AccountsAccountIdTrainingShapesTrainingShapeIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.readMask != null) query.append("readMask", String(args.readMask)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/accounts/${encodeURIComponent(String(args.account_id))}/trainingShapes/${encodeURIComponent(String(args.training_shape_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(gatewayTrainingShape, await res.json()) };