/* * 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 { VectorSearchResultContent, VectorSearchResultContent$inboundSchema, VectorSearchResultContent$Outbound, VectorSearchResultContent$outboundSchema, } from "./vectorsearchresultcontent.js"; export type VectorSearchResultAttributes = string | boolean | number; /** * A single search result from a vector store search. */ export type VectorSearchResult = { /** * The ID of the file containing this result. */ fileId: string; /** * The name of the file. */ filename: string; /** * The relevance score of this result. */ score: number; /** * File attributes. */ attributes?: { [k: string]: string | boolean | number } | undefined; /** * Array of content items. */ content: Array; }; /** @internal */ export const VectorSearchResultAttributes$inboundSchema: z.ZodType< VectorSearchResultAttributes, z.ZodTypeDef, unknown > = z.union([z.string(), z.boolean(), z.number()]); /** @internal */ export type VectorSearchResultAttributes$Outbound = string | boolean | number; /** @internal */ export const VectorSearchResultAttributes$outboundSchema: z.ZodType< VectorSearchResultAttributes$Outbound, z.ZodTypeDef, VectorSearchResultAttributes > = z.union([z.string(), z.boolean(), z.number()]); export function vectorSearchResultAttributesToJSON( vectorSearchResultAttributes: VectorSearchResultAttributes, ): string { return JSON.stringify( VectorSearchResultAttributes$outboundSchema.parse( vectorSearchResultAttributes, ), ); } export function vectorSearchResultAttributesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VectorSearchResultAttributes$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VectorSearchResultAttributes' from JSON`, ); } /** @internal */ export const VectorSearchResult$inboundSchema: z.ZodType< VectorSearchResult, z.ZodTypeDef, unknown > = z.object({ file_id: z.string(), filename: z.string(), score: z.number(), attributes: z.record(z.union([z.string(), z.boolean(), z.number()])) .optional(), content: z.array(VectorSearchResultContent$inboundSchema), }).transform((v) => { return remap$(v, { "file_id": "fileId", }); }); /** @internal */ export type VectorSearchResult$Outbound = { file_id: string; filename: string; score: number; attributes?: { [k: string]: string | boolean | number } | undefined; content: Array; }; /** @internal */ export const VectorSearchResult$outboundSchema: z.ZodType< VectorSearchResult$Outbound, z.ZodTypeDef, VectorSearchResult > = z.object({ fileId: z.string(), filename: z.string(), score: z.number(), attributes: z.record(z.union([z.string(), z.boolean(), z.number()])) .optional(), content: z.array(VectorSearchResultContent$outboundSchema), }).transform((v) => { return remap$(v, { fileId: "file_id", }); }); export function vectorSearchResultToJSON( vectorSearchResult: VectorSearchResult, ): string { return JSON.stringify( VectorSearchResult$outboundSchema.parse(vectorSearchResult), ); } export function vectorSearchResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VectorSearchResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VectorSearchResult' from JSON`, ); }