/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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"; export type RetrieveDocumentsRequest = { /** * The name of the index to retrieve documents from */ indexName: string; /** * The search query used for retrieving documents */ query: string; /** * The number of documents to retrieve */ topK: number; /** * Between 0 and 1, configures balance between keyword and semantic retrieval */ alpha?: number | undefined; /** * Whether to rerank the results after retrieval */ rerank?: boolean | undefined; /** * The filter object is used to specify query criteria for filtering results. * * @remarks * Each key in the filter object represents a field name, and its value is a dictionary * of comparison operators. Logical operators can be used within these dictionaries * to combine multiple conditions. * * - **Comparison Operators**: * - **`$eq`**: Checks if a field is equal to a specified value (string, number, or boolean). * - Simplified form: `"field1": "value1"` is equivalent to `"field1": {"$eq": "value1"}`. * - **`$ne`**: Checks if a field is not equal to a specified value (string, number, or boolean). * - **`$gt`**: Checks if a field is greater than a specified numeric value. * - **`$gte`**: Checks if a field is greater than or equal to a specified numeric value. * - **`$lt`**: Checks if a field is less than a specified numeric value. * - **`$lte`**: Checks if a field is less than or equal to a specified numeric value. * - **`$in`**: Checks if a field's value is within a specified list of values (strings, numbers). * - **`$nin`**: Checks if a field's value is not within a specified list of values (strings, numbers). * * - **Logical Operators** (used within field-specific dictionaries): * - **`$and`**: An array of filter objects, all of which must evaluate to true. * - **`$or`**: An array of filter objects, at least one of which must evaluate to true. * * Example: * ```json * { * "field1": "value1", // Simplified equals check * "field2": {"$gt": 10}, * "field3": { * "$or": [ * {"$in": ["value2", "value3"]}, * {"$ne": "value4"} * ] * } * } * ``` */ metadataFilter?: { [k: string]: any } | undefined; }; /** @internal */ export const RetrieveDocumentsRequest$inboundSchema: z.ZodType< RetrieveDocumentsRequest, z.ZodTypeDef, unknown > = z.object({ index_name: z.string(), query: z.string(), top_k: z.number().int(), alpha: z.number().optional(), rerank: z.boolean().optional(), metadata_filter: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { "index_name": "indexName", "top_k": "topK", "metadata_filter": "metadataFilter", }); }); /** @internal */ export type RetrieveDocumentsRequest$Outbound = { index_name: string; query: string; top_k: number; alpha?: number | undefined; rerank?: boolean | undefined; metadata_filter?: { [k: string]: any } | undefined; }; /** @internal */ export const RetrieveDocumentsRequest$outboundSchema: z.ZodType< RetrieveDocumentsRequest$Outbound, z.ZodTypeDef, RetrieveDocumentsRequest > = z.object({ indexName: z.string(), query: z.string(), topK: z.number().int(), alpha: z.number().optional(), rerank: z.boolean().optional(), metadataFilter: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { indexName: "index_name", topK: "top_k", metadataFilter: "metadata_filter", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RetrieveDocumentsRequest$ { /** @deprecated use `RetrieveDocumentsRequest$inboundSchema` instead. */ export const inboundSchema = RetrieveDocumentsRequest$inboundSchema; /** @deprecated use `RetrieveDocumentsRequest$outboundSchema` instead. */ export const outboundSchema = RetrieveDocumentsRequest$outboundSchema; /** @deprecated use `RetrieveDocumentsRequest$Outbound` instead. */ export type Outbound = RetrieveDocumentsRequest$Outbound; } export function retrieveDocumentsRequestToJSON( retrieveDocumentsRequest: RetrieveDocumentsRequest, ): string { return JSON.stringify( RetrieveDocumentsRequest$outboundSchema.parse(retrieveDocumentsRequest), ); } export function retrieveDocumentsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RetrieveDocumentsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RetrieveDocumentsRequest' from JSON`, ); }