/* * 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 { FileCounts, FileCounts$inboundSchema, FileCounts$Outbound, FileCounts$outboundSchema, } from "./filecounts.js"; /** * Retrieval mode, frozen at creation. 'vector': standard vector similarity search. 'graph': GraphRAG — entities and relations are extracted at ingest and queries traverse the knowledge graph. 'hybrid' is reserved. */ export const VectorStoreRetrievalMode = { Vector: "vector", Hybrid: "hybrid", Graph: "graph", } as const; /** * Retrieval mode, frozen at creation. 'vector': standard vector similarity search. 'graph': GraphRAG — entities and relations are extracted at ingest and queries traverse the knowledge graph. 'hybrid' is reserved. */ export type VectorStoreRetrievalMode = ClosedEnum< typeof VectorStoreRetrievalMode >; /** * The status of the vector store. 'expired' means the store has expired, 'in_progress' means files are still being processed, 'completed' indicates that the vector store is ready for use. */ export const VectorStoreStatus = { Expired: "expired", InProgress: "in_progress", Completed: "completed", } as const; /** * The status of the vector store. 'expired' means the store has expired, 'in_progress' means files are still being processed, 'completed' indicates that the vector store is ready for use. */ export type VectorStoreStatus = ClosedEnum; /** * The expiration policy for a vector store. */ export type VectorStoreExpiresAfter = { /** * 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; }; export type VectorStoreMetadata = string | boolean | number; /** * A vector store is a collection of processed files that can be used by the file_search tool. */ export type VectorStore = { /** * The identifier, which can be referenced in API endpoints. */ id: string; /** * The object type, which is always 'vector_store'. */ object: "vector_store"; /** * The Unix timestamp (in seconds) for when the vector store was created. */ createdAt: number; /** * The name of the vector store. */ name: string | null; /** * The total number of bytes used by the files in the vector store. */ usageBytes: number; /** * The embedding model used for this vector store. Resolved at creation time from the requested or auto model. Null for legacy vector stores. */ embeddingModel: string | null; /** * The number of dimensions for the embedding vectors in this vector store. Null for legacy vector stores. */ embeddingDimensions: number | null; /** * Retrieval mode, frozen at creation. 'vector': standard vector similarity search. 'graph': GraphRAG — entities and relations are extracted at ingest and queries traverse the knowledge graph. 'hybrid' is reserved. */ retrievalMode: VectorStoreRetrievalMode; /** * The model used for entity/relation extraction on graph stores. Null for non-graph stores. */ extractionModel?: string | null | undefined; /** * Graph expansion depth for graph-mode queries. Null for non-graph stores. */ maxHops?: number | null | undefined; /** * File processing status counts. */ fileCounts: FileCounts; /** * The status of the vector store. 'expired' means the store has expired, 'in_progress' means files are still being processed, 'completed' indicates that the vector store is ready for use. */ status: VectorStoreStatus; /** * The expiration policy for a vector store. */ expiresAfter?: VectorStoreExpiresAfter | undefined; /** * The Unix timestamp (in seconds) for when the vector store will expire. */ expiresAt?: number | null | undefined; /** * The Unix timestamp (in seconds) for when the vector store was last active. */ lastActiveAt: number | null; /** * 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. */ metadata: { [k: string]: string | boolean | number }; /** * A description for the vector store. Can be used to describe the vector store's purpose. */ description?: string | null | undefined; /** * The Unix timestamp (in seconds) for when the vector store was last used. */ lastUsedAt: number | null; }; /** @internal */ export const VectorStoreRetrievalMode$inboundSchema: z.ZodNativeEnum< typeof VectorStoreRetrievalMode > = z.nativeEnum(VectorStoreRetrievalMode); /** @internal */ export const VectorStoreRetrievalMode$outboundSchema: z.ZodNativeEnum< typeof VectorStoreRetrievalMode > = VectorStoreRetrievalMode$inboundSchema; /** @internal */ export const VectorStoreStatus$inboundSchema: z.ZodNativeEnum< typeof VectorStoreStatus > = z.nativeEnum(VectorStoreStatus); /** @internal */ export const VectorStoreStatus$outboundSchema: z.ZodNativeEnum< typeof VectorStoreStatus > = VectorStoreStatus$inboundSchema; /** @internal */ export const VectorStoreExpiresAfter$inboundSchema: z.ZodType< VectorStoreExpiresAfter, z.ZodTypeDef, unknown > = z.object({ anchor: z.literal("last_active_at"), days: z.number().int(), }); /** @internal */ export type VectorStoreExpiresAfter$Outbound = { anchor: "last_active_at"; days: number; }; /** @internal */ export const VectorStoreExpiresAfter$outboundSchema: z.ZodType< VectorStoreExpiresAfter$Outbound, z.ZodTypeDef, VectorStoreExpiresAfter > = z.object({ anchor: z.literal("last_active_at"), days: z.number().int(), }); export function vectorStoreExpiresAfterToJSON( vectorStoreExpiresAfter: VectorStoreExpiresAfter, ): string { return JSON.stringify( VectorStoreExpiresAfter$outboundSchema.parse(vectorStoreExpiresAfter), ); } export function vectorStoreExpiresAfterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VectorStoreExpiresAfter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VectorStoreExpiresAfter' from JSON`, ); } /** @internal */ export const VectorStoreMetadata$inboundSchema: z.ZodType< VectorStoreMetadata, z.ZodTypeDef, unknown > = z.union([z.string(), z.boolean(), z.number()]); /** @internal */ export type VectorStoreMetadata$Outbound = string | boolean | number; /** @internal */ export const VectorStoreMetadata$outboundSchema: z.ZodType< VectorStoreMetadata$Outbound, z.ZodTypeDef, VectorStoreMetadata > = z.union([z.string(), z.boolean(), z.number()]); export function vectorStoreMetadataToJSON( vectorStoreMetadata: VectorStoreMetadata, ): string { return JSON.stringify( VectorStoreMetadata$outboundSchema.parse(vectorStoreMetadata), ); } export function vectorStoreMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VectorStoreMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VectorStoreMetadata' from JSON`, ); } /** @internal */ export const VectorStore$inboundSchema: z.ZodType< VectorStore, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("vector_store"), created_at: z.number().int(), name: z.nullable(z.string()), usage_bytes: z.number().int(), embedding_model: z.nullable(z.string()), embedding_dimensions: z.nullable(z.number().int()), retrieval_mode: VectorStoreRetrievalMode$inboundSchema, extraction_model: z.nullable(z.string()).optional(), max_hops: z.nullable(z.number().int()).optional(), file_counts: FileCounts$inboundSchema, status: VectorStoreStatus$inboundSchema, expires_after: z.lazy(() => VectorStoreExpiresAfter$inboundSchema).optional(), expires_at: z.nullable(z.number().int()).optional(), last_active_at: z.nullable(z.number().int()), metadata: z.record(z.union([z.string(), z.boolean(), z.number()])), description: z.nullable(z.string()).optional(), last_used_at: z.nullable(z.number().int()), }).transform((v) => { return remap$(v, { "created_at": "createdAt", "usage_bytes": "usageBytes", "embedding_model": "embeddingModel", "embedding_dimensions": "embeddingDimensions", "retrieval_mode": "retrievalMode", "extraction_model": "extractionModel", "max_hops": "maxHops", "file_counts": "fileCounts", "expires_after": "expiresAfter", "expires_at": "expiresAt", "last_active_at": "lastActiveAt", "last_used_at": "lastUsedAt", }); }); /** @internal */ export type VectorStore$Outbound = { id: string; object: "vector_store"; created_at: number; name: string | null; usage_bytes: number; embedding_model: string | null; embedding_dimensions: number | null; retrieval_mode: string; extraction_model?: string | null | undefined; max_hops?: number | null | undefined; file_counts: FileCounts$Outbound; status: string; expires_after?: VectorStoreExpiresAfter$Outbound | undefined; expires_at?: number | null | undefined; last_active_at: number | null; metadata: { [k: string]: string | boolean | number }; description?: string | null | undefined; last_used_at: number | null; }; /** @internal */ export const VectorStore$outboundSchema: z.ZodType< VectorStore$Outbound, z.ZodTypeDef, VectorStore > = z.object({ id: z.string(), object: z.literal("vector_store"), createdAt: z.number().int(), name: z.nullable(z.string()), usageBytes: z.number().int(), embeddingModel: z.nullable(z.string()), embeddingDimensions: z.nullable(z.number().int()), retrievalMode: VectorStoreRetrievalMode$outboundSchema, extractionModel: z.nullable(z.string()).optional(), maxHops: z.nullable(z.number().int()).optional(), fileCounts: FileCounts$outboundSchema, status: VectorStoreStatus$outboundSchema, expiresAfter: z.lazy(() => VectorStoreExpiresAfter$outboundSchema).optional(), expiresAt: z.nullable(z.number().int()).optional(), lastActiveAt: z.nullable(z.number().int()), metadata: z.record(z.union([z.string(), z.boolean(), z.number()])), description: z.nullable(z.string()).optional(), lastUsedAt: z.nullable(z.number().int()), }).transform((v) => { return remap$(v, { createdAt: "created_at", usageBytes: "usage_bytes", embeddingModel: "embedding_model", embeddingDimensions: "embedding_dimensions", retrievalMode: "retrieval_mode", extractionModel: "extraction_model", maxHops: "max_hops", fileCounts: "file_counts", expiresAfter: "expires_after", expiresAt: "expires_at", lastActiveAt: "last_active_at", lastUsedAt: "last_used_at", }); }); export function vectorStoreToJSON(vectorStore: VectorStore): string { return JSON.stringify(VectorStore$outboundSchema.parse(vectorStore)); } export function vectorStoreFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VectorStore$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VectorStore' from JSON`, ); }