/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AutoChunkingStrategy, AutoChunkingStrategy$inboundSchema, AutoChunkingStrategy$Outbound, AutoChunkingStrategy$outboundSchema, } from "./autochunkingstrategy.js"; import { FileWithMetadata, FileWithMetadata$inboundSchema, FileWithMetadata$Outbound, FileWithMetadata$outboundSchema, } from "./filewithmetadata.js"; import { StaticChunkingStrategy, StaticChunkingStrategy$inboundSchema, StaticChunkingStrategy$Outbound, StaticChunkingStrategy$outboundSchema, } from "./staticchunkingstrategy.js"; export type CreateVectorStoreFileBatchRequestAttributes = | string | boolean | number; /** * Batch-wide default chunking strategy, applied to every file that does not carry its own (a 'files' entry's chunking_strategy overrides this). */ export type CreateVectorStoreFileBatchRequestChunkingStrategy = | AutoChunkingStrategy | StaticChunkingStrategy; /** * Request body for creating a vector store file batch. */ export type CreateVectorStoreFileBatchRequest = { /** * A list of File IDs that the vector store should use. If attributes or chunking_strategy are provided at the root level, they will be applied to all files in the batch. Mutually exclusive with 'files'. At most 500 per batch. */ fileIds?: Array | undefined; /** * A list of objects that each include a file_id plus optional attributes or chunking_strategy. Use this when you need to override metadata for specific files. Entries without their own attributes or chunking_strategy fall back to the request-level values. Mutually exclusive with 'file_ids'. At most 500 per batch. */ files?: Array | undefined; /** * Batch-wide default attributes, applied to every file that does not carry its own (a 'files' entry's attributes override this). */ attributes?: { [k: string]: string | boolean | number } | undefined; /** * Batch-wide default chunking strategy, applied to every file that does not carry its own (a 'files' entry's chunking_strategy overrides this). */ chunkingStrategy?: AutoChunkingStrategy | StaticChunkingStrategy | undefined; }; /** @internal */ export const CreateVectorStoreFileBatchRequestAttributes$inboundSchema: z.ZodType< CreateVectorStoreFileBatchRequestAttributes, z.ZodTypeDef, unknown > = z.union([z.string(), z.boolean(), z.number()]); /** @internal */ export type CreateVectorStoreFileBatchRequestAttributes$Outbound = | string | boolean | number; /** @internal */ export const CreateVectorStoreFileBatchRequestAttributes$outboundSchema: z.ZodType< CreateVectorStoreFileBatchRequestAttributes$Outbound, z.ZodTypeDef, CreateVectorStoreFileBatchRequestAttributes > = z.union([z.string(), z.boolean(), z.number()]); export function createVectorStoreFileBatchRequestAttributesToJSON( createVectorStoreFileBatchRequestAttributes: CreateVectorStoreFileBatchRequestAttributes, ): string { return JSON.stringify( CreateVectorStoreFileBatchRequestAttributes$outboundSchema.parse( createVectorStoreFileBatchRequestAttributes, ), ); } export function createVectorStoreFileBatchRequestAttributesFromJSON( jsonString: string, ): SafeParseResult< CreateVectorStoreFileBatchRequestAttributes, SDKValidationError > { return safeParse( jsonString, (x) => CreateVectorStoreFileBatchRequestAttributes$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CreateVectorStoreFileBatchRequestAttributes' from JSON`, ); } /** @internal */ export const CreateVectorStoreFileBatchRequestChunkingStrategy$inboundSchema: z.ZodType< CreateVectorStoreFileBatchRequestChunkingStrategy, z.ZodTypeDef, unknown > = z.union([ AutoChunkingStrategy$inboundSchema, StaticChunkingStrategy$inboundSchema, ]); /** @internal */ export type CreateVectorStoreFileBatchRequestChunkingStrategy$Outbound = | AutoChunkingStrategy$Outbound | StaticChunkingStrategy$Outbound; /** @internal */ export const CreateVectorStoreFileBatchRequestChunkingStrategy$outboundSchema: z.ZodType< CreateVectorStoreFileBatchRequestChunkingStrategy$Outbound, z.ZodTypeDef, CreateVectorStoreFileBatchRequestChunkingStrategy > = z.union([ AutoChunkingStrategy$outboundSchema, StaticChunkingStrategy$outboundSchema, ]); export function createVectorStoreFileBatchRequestChunkingStrategyToJSON( createVectorStoreFileBatchRequestChunkingStrategy: CreateVectorStoreFileBatchRequestChunkingStrategy, ): string { return JSON.stringify( CreateVectorStoreFileBatchRequestChunkingStrategy$outboundSchema.parse( createVectorStoreFileBatchRequestChunkingStrategy, ), ); } export function createVectorStoreFileBatchRequestChunkingStrategyFromJSON( jsonString: string, ): SafeParseResult< CreateVectorStoreFileBatchRequestChunkingStrategy, SDKValidationError > { return safeParse( jsonString, (x) => CreateVectorStoreFileBatchRequestChunkingStrategy$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CreateVectorStoreFileBatchRequestChunkingStrategy' from JSON`, ); } /** @internal */ export const CreateVectorStoreFileBatchRequest$inboundSchema: z.ZodType< CreateVectorStoreFileBatchRequest, z.ZodTypeDef, unknown > = z.object({ file_ids: z.array(z.string()).optional(), files: z.array(FileWithMetadata$inboundSchema).optional(), attributes: z.record(z.union([z.string(), z.boolean(), z.number()])) .optional(), chunking_strategy: z.union([ AutoChunkingStrategy$inboundSchema, StaticChunkingStrategy$inboundSchema, ]).optional(), }).transform((v) => { return remap$(v, { "file_ids": "fileIds", "chunking_strategy": "chunkingStrategy", }); }); /** @internal */ export type CreateVectorStoreFileBatchRequest$Outbound = { file_ids?: Array | undefined; files?: Array | undefined; attributes?: { [k: string]: string | boolean | number } | undefined; chunking_strategy?: | AutoChunkingStrategy$Outbound | StaticChunkingStrategy$Outbound | undefined; }; /** @internal */ export const CreateVectorStoreFileBatchRequest$outboundSchema: z.ZodType< CreateVectorStoreFileBatchRequest$Outbound, z.ZodTypeDef, CreateVectorStoreFileBatchRequest > = z.object({ fileIds: z.array(z.string()).optional(), files: z.array(FileWithMetadata$outboundSchema).optional(), attributes: z.record(z.union([z.string(), z.boolean(), z.number()])) .optional(), chunkingStrategy: z.union([ AutoChunkingStrategy$outboundSchema, StaticChunkingStrategy$outboundSchema, ]).optional(), }).transform((v) => { return remap$(v, { fileIds: "file_ids", chunkingStrategy: "chunking_strategy", }); }); export function createVectorStoreFileBatchRequestToJSON( createVectorStoreFileBatchRequest: CreateVectorStoreFileBatchRequest, ): string { return JSON.stringify( CreateVectorStoreFileBatchRequest$outboundSchema.parse( createVectorStoreFileBatchRequest, ), ); } export function createVectorStoreFileBatchRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateVectorStoreFileBatchRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateVectorStoreFileBatchRequest' from JSON`, ); }