/* * 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"; import { AskIndexResponseSource, AskIndexResponseSource$inboundSchema, AskIndexResponseSource$Outbound, AskIndexResponseSource$outboundSchema, } from "./askindexresponsesource.js"; export type AskIndexResponse = { /** * Reserved for future use - conversation thread identifier */ threadId?: string | null | undefined; /** * The synthesized answer to the question */ answer: string; /** * Confidence score for the answer quality (0 to 1000) */ confidence: number; /** * List of source documents that contributed to the answer */ sources: Array; }; /** @internal */ export const AskIndexResponse$inboundSchema: z.ZodType< AskIndexResponse, z.ZodTypeDef, unknown > = z.object({ thread_id: z.nullable(z.string()).optional(), answer: z.string(), confidence: z.number().int(), sources: z.array(AskIndexResponseSource$inboundSchema), }).transform((v) => { return remap$(v, { "thread_id": "threadId", }); }); /** @internal */ export type AskIndexResponse$Outbound = { thread_id?: string | null | undefined; answer: string; confidence: number; sources: Array; }; /** @internal */ export const AskIndexResponse$outboundSchema: z.ZodType< AskIndexResponse$Outbound, z.ZodTypeDef, AskIndexResponse > = z.object({ threadId: z.nullable(z.string()).optional(), answer: z.string(), confidence: z.number().int(), sources: z.array(AskIndexResponseSource$outboundSchema), }).transform((v) => { return remap$(v, { threadId: "thread_id", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AskIndexResponse$ { /** @deprecated use `AskIndexResponse$inboundSchema` instead. */ export const inboundSchema = AskIndexResponse$inboundSchema; /** @deprecated use `AskIndexResponse$outboundSchema` instead. */ export const outboundSchema = AskIndexResponse$outboundSchema; /** @deprecated use `AskIndexResponse$Outbound` instead. */ export type Outbound = AskIndexResponse$Outbound; } export function askIndexResponseToJSON( askIndexResponse: AskIndexResponse, ): string { return JSON.stringify( AskIndexResponse$outboundSchema.parse(askIndexResponse), ); } export function askIndexResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AskIndexResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AskIndexResponse' from JSON`, ); }