/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: d9b040a2c084 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FollowupAction, FollowupAction$inboundSchema, FollowupAction$Outbound, FollowupAction$outboundSchema, } from "./followupaction.js"; import { TextRange, TextRange$inboundSchema, TextRange$Outbound, TextRange$outboundSchema, } from "./textrange.js"; /** * Status of backend generating the answer */ export const GeneratedQnaStatus = { Computing: "COMPUTING", Disabled: "DISABLED", Failed: "FAILED", NoAnswer: "NO_ANSWER", Skipped: "SKIPPED", Streaming: "STREAMING", Succeeded: "SUCCEEDED", Timeout: "TIMEOUT", } as const; /** * Status of backend generating the answer */ export type GeneratedQnaStatus = OpenEnum; export type GeneratedQna = { /** * Search query rephrased into a question. */ question?: string | undefined; /** * Answer generated for the given query or the generated question. */ answer?: string | undefined; /** * List of all follow-up prompts generated for the given query or the generated question. */ followUpPrompts?: Array | undefined; /** * List of follow-up actions generated for the given query or the generated question. */ followupActions?: Array | undefined; /** * Answer subsections to mark with special formatting (citations, bolding etc) */ ranges?: Array | undefined; /** * Status of backend generating the answer */ status?: GeneratedQnaStatus | undefined; /** * An opaque cursor representing the search request */ cursor?: string | undefined; /** * An opaque token that represents this particular result in this particular query. To be used for /feedback reporting. */ trackingToken?: string | undefined; }; /** @internal */ export const GeneratedQnaStatus$inboundSchema: z.ZodType< GeneratedQnaStatus, z.ZodTypeDef, unknown > = openEnums.inboundSchema(GeneratedQnaStatus); /** @internal */ export const GeneratedQnaStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, GeneratedQnaStatus > = openEnums.outboundSchema(GeneratedQnaStatus); /** @internal */ export const GeneratedQna$inboundSchema: z.ZodType< GeneratedQna, z.ZodTypeDef, unknown > = z.object({ question: z.string().optional(), answer: z.string().optional(), followUpPrompts: z.array(z.string()).optional(), followupActions: z.array(FollowupAction$inboundSchema).optional(), ranges: z.array(z.lazy(() => TextRange$inboundSchema)).optional(), status: GeneratedQnaStatus$inboundSchema.optional(), cursor: z.string().optional(), trackingToken: z.string().optional(), }); /** @internal */ export type GeneratedQna$Outbound = { question?: string | undefined; answer?: string | undefined; followUpPrompts?: Array | undefined; followupActions?: Array | undefined; ranges?: Array | undefined; status?: string | undefined; cursor?: string | undefined; trackingToken?: string | undefined; }; /** @internal */ export const GeneratedQna$outboundSchema: z.ZodType< GeneratedQna$Outbound, z.ZodTypeDef, GeneratedQna > = z.object({ question: z.string().optional(), answer: z.string().optional(), followUpPrompts: z.array(z.string()).optional(), followupActions: z.array(FollowupAction$outboundSchema).optional(), ranges: z.array(z.lazy(() => TextRange$outboundSchema)).optional(), status: GeneratedQnaStatus$outboundSchema.optional(), cursor: z.string().optional(), trackingToken: z.string().optional(), }); export function generatedQnaToJSON(generatedQna: GeneratedQna): string { return JSON.stringify(GeneratedQna$outboundSchema.parse(generatedQna)); } export function generatedQnaFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GeneratedQna$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GeneratedQna' from JSON`, ); }