/* * 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 { StaticChunkingStrategy, StaticChunkingStrategy$inboundSchema, StaticChunkingStrategy$Outbound, StaticChunkingStrategy$outboundSchema, } from "./staticchunkingstrategy.js"; export type CreateVectorStoreFileRequestAttributes = string | boolean | number; /** * The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. */ export type CreateVectorStoreFileRequestChunkingStrategy = | AutoChunkingStrategy | StaticChunkingStrategy; /** * Request body for creating a vector store file. */ export type CreateVectorStoreFileRequest = { /** * A File ID that the vector store should use. Useful for tools like file_search that can access files. */ fileId: string; /** * Set of 16 key-value pairs that can be attached to an object. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers. */ attributes?: { [k: string]: string | boolean | number } | undefined; /** * The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. */ chunkingStrategy?: AutoChunkingStrategy | StaticChunkingStrategy | undefined; }; /** @internal */ export const CreateVectorStoreFileRequestAttributes$inboundSchema: z.ZodType< CreateVectorStoreFileRequestAttributes, z.ZodTypeDef, unknown > = z.union([z.string(), z.boolean(), z.number()]); /** @internal */ export type CreateVectorStoreFileRequestAttributes$Outbound = | string | boolean | number; /** @internal */ export const CreateVectorStoreFileRequestAttributes$outboundSchema: z.ZodType< CreateVectorStoreFileRequestAttributes$Outbound, z.ZodTypeDef, CreateVectorStoreFileRequestAttributes > = z.union([z.string(), z.boolean(), z.number()]); export function createVectorStoreFileRequestAttributesToJSON( createVectorStoreFileRequestAttributes: CreateVectorStoreFileRequestAttributes, ): string { return JSON.stringify( CreateVectorStoreFileRequestAttributes$outboundSchema.parse( createVectorStoreFileRequestAttributes, ), ); } export function createVectorStoreFileRequestAttributesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateVectorStoreFileRequestAttributes$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateVectorStoreFileRequestAttributes' from JSON`, ); } /** @internal */ export const CreateVectorStoreFileRequestChunkingStrategy$inboundSchema: z.ZodType< CreateVectorStoreFileRequestChunkingStrategy, z.ZodTypeDef, unknown > = z.union([ AutoChunkingStrategy$inboundSchema, StaticChunkingStrategy$inboundSchema, ]); /** @internal */ export type CreateVectorStoreFileRequestChunkingStrategy$Outbound = | AutoChunkingStrategy$Outbound | StaticChunkingStrategy$Outbound; /** @internal */ export const CreateVectorStoreFileRequestChunkingStrategy$outboundSchema: z.ZodType< CreateVectorStoreFileRequestChunkingStrategy$Outbound, z.ZodTypeDef, CreateVectorStoreFileRequestChunkingStrategy > = z.union([ AutoChunkingStrategy$outboundSchema, StaticChunkingStrategy$outboundSchema, ]); export function createVectorStoreFileRequestChunkingStrategyToJSON( createVectorStoreFileRequestChunkingStrategy: CreateVectorStoreFileRequestChunkingStrategy, ): string { return JSON.stringify( CreateVectorStoreFileRequestChunkingStrategy$outboundSchema.parse( createVectorStoreFileRequestChunkingStrategy, ), ); } export function createVectorStoreFileRequestChunkingStrategyFromJSON( jsonString: string, ): SafeParseResult< CreateVectorStoreFileRequestChunkingStrategy, SDKValidationError > { return safeParse( jsonString, (x) => CreateVectorStoreFileRequestChunkingStrategy$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CreateVectorStoreFileRequestChunkingStrategy' from JSON`, ); } /** @internal */ export const CreateVectorStoreFileRequest$inboundSchema: z.ZodType< CreateVectorStoreFileRequest, z.ZodTypeDef, unknown > = z.object({ file_id: z.string(), 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_id": "fileId", "chunking_strategy": "chunkingStrategy", }); }); /** @internal */ export type CreateVectorStoreFileRequest$Outbound = { file_id: string; attributes?: { [k: string]: string | boolean | number } | undefined; chunking_strategy?: | AutoChunkingStrategy$Outbound | StaticChunkingStrategy$Outbound | undefined; }; /** @internal */ export const CreateVectorStoreFileRequest$outboundSchema: z.ZodType< CreateVectorStoreFileRequest$Outbound, z.ZodTypeDef, CreateVectorStoreFileRequest > = z.object({ fileId: z.string(), 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, { fileId: "file_id", chunkingStrategy: "chunking_strategy", }); }); export function createVectorStoreFileRequestToJSON( createVectorStoreFileRequest: CreateVectorStoreFileRequest, ): string { return JSON.stringify( CreateVectorStoreFileRequest$outboundSchema.parse( createVectorStoreFileRequest, ), ); } export function createVectorStoreFileRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateVectorStoreFileRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateVectorStoreFileRequest' from JSON`, ); }