/* * 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 { ClosedEnum } from "../../types/enums.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"; /** * The expiration policy for a vector store. */ export type ExpiresAfter = { /** * Anchor timestamp after which the expiration policy applies. Supported anchors: last_active_at. */ anchor: "last_active_at"; /** * The number of days after the anchor time that the vector store will expire. */ days: number; }; /** * The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. */ export type CreateVectorStoreRequestChunkingStrategy = | AutoChunkingStrategy | StaticChunkingStrategy; /** * Retrieval mode, frozen at creation (cannot be changed later). 'vector' (default): standard vector similarity search. 'graph': GraphRAG — entities and relations are extracted from every chunk at ingest (metered against your usage) and search traverses the knowledge graph. */ export const RetrievalMode = { Vector: "vector", Graph: "graph", } as const; /** * Retrieval mode, frozen at creation (cannot be changed later). 'vector' (default): standard vector similarity search. 'graph': GraphRAG — entities and relations are extracted from every chunk at ingest (metered against your usage) and search traverses the knowledge graph. */ export type RetrievalMode = ClosedEnum; /** * Request body for creating a vector store. */ export type CreateVectorStoreRequest = { /** * The name of the vector store. */ name?: string | undefined; /** * A description for the vector store. Can be used to describe the vector store's purpose. */ description?: string | undefined; /** * A list of File IDs that the vector store should use. Useful for tools like file_search that can access files. At most 500 per request. */ fileIds?: Array | undefined; /** * The expiration policy for a vector store. */ expiresAfter?: ExpiresAfter | undefined; /** * The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. */ chunkingStrategy?: AutoChunkingStrategy | StaticChunkingStrategy | undefined; /** * 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. */ metadata?: { [k: string]: string } | undefined; /** * The embedding model to use. Defaults to the auto-configured model if not specified. */ embeddingModel?: string | undefined; /** * The number of dimensions for the embedding vectors. Only supported for models with flexible dimensions. If not specified, uses the model's default dimensions. */ embeddingDimensions?: number | undefined; /** * Retrieval mode, frozen at creation (cannot be changed later). 'vector' (default): standard vector similarity search. 'graph': GraphRAG — entities and relations are extracted from every chunk at ingest (metered against your usage) and search traverses the knowledge graph. */ retrievalMode?: RetrievalMode | undefined; /** * Model used for entity/relation extraction on graph stores (ingest-time triplet extraction and query-entity extraction). Defaults to the auto-configured model, resolved at creation time — same contract as embedding_model. Only valid when retrieval_mode is 'graph'. */ extractionModel?: string | undefined; /** * Graph expansion depth for graph-mode queries (1-4, engine default 2). Only valid for graph stores. */ maxHops?: number | undefined; }; /** @internal */ export const ExpiresAfter$inboundSchema: z.ZodType< ExpiresAfter, z.ZodTypeDef, unknown > = z.object({ anchor: z.literal("last_active_at"), days: z.number().int(), }); /** @internal */ export type ExpiresAfter$Outbound = { anchor: "last_active_at"; days: number; }; /** @internal */ export const ExpiresAfter$outboundSchema: z.ZodType< ExpiresAfter$Outbound, z.ZodTypeDef, ExpiresAfter > = z.object({ anchor: z.literal("last_active_at"), days: z.number().int(), }); export function expiresAfterToJSON(expiresAfter: ExpiresAfter): string { return JSON.stringify(ExpiresAfter$outboundSchema.parse(expiresAfter)); } export function expiresAfterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExpiresAfter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExpiresAfter' from JSON`, ); } /** @internal */ export const CreateVectorStoreRequestChunkingStrategy$inboundSchema: z.ZodType< CreateVectorStoreRequestChunkingStrategy, z.ZodTypeDef, unknown > = z.union([ AutoChunkingStrategy$inboundSchema, StaticChunkingStrategy$inboundSchema, ]); /** @internal */ export type CreateVectorStoreRequestChunkingStrategy$Outbound = | AutoChunkingStrategy$Outbound | StaticChunkingStrategy$Outbound; /** @internal */ export const CreateVectorStoreRequestChunkingStrategy$outboundSchema: z.ZodType< CreateVectorStoreRequestChunkingStrategy$Outbound, z.ZodTypeDef, CreateVectorStoreRequestChunkingStrategy > = z.union([ AutoChunkingStrategy$outboundSchema, StaticChunkingStrategy$outboundSchema, ]); export function createVectorStoreRequestChunkingStrategyToJSON( createVectorStoreRequestChunkingStrategy: CreateVectorStoreRequestChunkingStrategy, ): string { return JSON.stringify( CreateVectorStoreRequestChunkingStrategy$outboundSchema.parse( createVectorStoreRequestChunkingStrategy, ), ); } export function createVectorStoreRequestChunkingStrategyFromJSON( jsonString: string, ): SafeParseResult< CreateVectorStoreRequestChunkingStrategy, SDKValidationError > { return safeParse( jsonString, (x) => CreateVectorStoreRequestChunkingStrategy$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CreateVectorStoreRequestChunkingStrategy' from JSON`, ); } /** @internal */ export const RetrievalMode$inboundSchema: z.ZodNativeEnum< typeof RetrievalMode > = z.nativeEnum(RetrievalMode); /** @internal */ export const RetrievalMode$outboundSchema: z.ZodNativeEnum< typeof RetrievalMode > = RetrievalMode$inboundSchema; /** @internal */ export const CreateVectorStoreRequest$inboundSchema: z.ZodType< CreateVectorStoreRequest, z.ZodTypeDef, unknown > = z.object({ name: z.string().optional(), description: z.string().optional(), file_ids: z.array(z.string()).optional(), expires_after: z.lazy(() => ExpiresAfter$inboundSchema).optional(), chunking_strategy: z.union([ AutoChunkingStrategy$inboundSchema, StaticChunkingStrategy$inboundSchema, ]).optional(), metadata: z.record(z.string()).optional(), embedding_model: z.string().optional(), embedding_dimensions: z.number().int().optional(), retrieval_mode: RetrievalMode$inboundSchema.optional(), extraction_model: z.string().optional(), max_hops: z.number().int().optional(), }).transform((v) => { return remap$(v, { "file_ids": "fileIds", "expires_after": "expiresAfter", "chunking_strategy": "chunkingStrategy", "embedding_model": "embeddingModel", "embedding_dimensions": "embeddingDimensions", "retrieval_mode": "retrievalMode", "extraction_model": "extractionModel", "max_hops": "maxHops", }); }); /** @internal */ export type CreateVectorStoreRequest$Outbound = { name?: string | undefined; description?: string | undefined; file_ids?: Array | undefined; expires_after?: ExpiresAfter$Outbound | undefined; chunking_strategy?: | AutoChunkingStrategy$Outbound | StaticChunkingStrategy$Outbound | undefined; metadata?: { [k: string]: string } | undefined; embedding_model?: string | undefined; embedding_dimensions?: number | undefined; retrieval_mode?: string | undefined; extraction_model?: string | undefined; max_hops?: number | undefined; }; /** @internal */ export const CreateVectorStoreRequest$outboundSchema: z.ZodType< CreateVectorStoreRequest$Outbound, z.ZodTypeDef, CreateVectorStoreRequest > = z.object({ name: z.string().optional(), description: z.string().optional(), fileIds: z.array(z.string()).optional(), expiresAfter: z.lazy(() => ExpiresAfter$outboundSchema).optional(), chunkingStrategy: z.union([ AutoChunkingStrategy$outboundSchema, StaticChunkingStrategy$outboundSchema, ]).optional(), metadata: z.record(z.string()).optional(), embeddingModel: z.string().optional(), embeddingDimensions: z.number().int().optional(), retrievalMode: RetrievalMode$outboundSchema.optional(), extractionModel: z.string().optional(), maxHops: z.number().int().optional(), }).transform((v) => { return remap$(v, { fileIds: "file_ids", expiresAfter: "expires_after", chunkingStrategy: "chunking_strategy", embeddingModel: "embedding_model", embeddingDimensions: "embedding_dimensions", retrievalMode: "retrieval_mode", extractionModel: "extraction_model", maxHops: "max_hops", }); }); export function createVectorStoreRequestToJSON( createVectorStoreRequest: CreateVectorStoreRequest, ): string { return JSON.stringify( CreateVectorStoreRequest$outboundSchema.parse(createVectorStoreRequest), ); } export function createVectorStoreRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateVectorStoreRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateVectorStoreRequest' from JSON`, ); }