/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ContainerFileCitation, ContainerFileCitation$inboundSchema, ContainerFileCitation$Outbound, ContainerFileCitation$outboundSchema, } from "./containerfilecitation.js"; import { FileCitation, FileCitation$inboundSchema, FileCitation$Outbound, FileCitation$outboundSchema, } from "./filecitation.js"; import { FilePath, FilePath$inboundSchema, FilePath$Outbound, FilePath$outboundSchema, } from "./filepath.js"; import { LogProb, LogProb$inboundSchema, LogProb$Outbound, LogProb$outboundSchema, } from "./logprob.js"; import { URLCitation, URLCitation$inboundSchema, URLCitation$Outbound, URLCitation$outboundSchema, } from "./urlcitation.js"; export type Annotations = | FileCitation | URLCitation | ContainerFileCitation | FilePath; /** * Text content output from the model with optional annotations for citations and file references. */ export type OutputText = { /** * The content type identifier for text output. */ type: "output_text"; /** * The generated text content from the model. */ text: string; /** * Array of annotations providing citations and references for the text. Used to attribute sources and reference files mentioned in the output. */ annotations?: | Array | undefined; logprobs?: Array | undefined; }; /** @internal */ export const Annotations$inboundSchema: z.ZodType< Annotations, z.ZodTypeDef, unknown > = z.union([ FileCitation$inboundSchema, URLCitation$inboundSchema, ContainerFileCitation$inboundSchema, FilePath$inboundSchema, ]); /** @internal */ export type Annotations$Outbound = | FileCitation$Outbound | URLCitation$Outbound | ContainerFileCitation$Outbound | FilePath$Outbound; /** @internal */ export const Annotations$outboundSchema: z.ZodType< Annotations$Outbound, z.ZodTypeDef, Annotations > = z.union([ FileCitation$outboundSchema, URLCitation$outboundSchema, ContainerFileCitation$outboundSchema, FilePath$outboundSchema, ]); export function annotationsToJSON(annotations: Annotations): string { return JSON.stringify(Annotations$outboundSchema.parse(annotations)); } export function annotationsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Annotations$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Annotations' from JSON`, ); } /** @internal */ export const OutputText$inboundSchema: z.ZodType< OutputText, z.ZodTypeDef, unknown > = z.object({ type: z.literal("output_text"), text: z.string(), annotations: z.array( z.union([ FileCitation$inboundSchema, URLCitation$inboundSchema, ContainerFileCitation$inboundSchema, FilePath$inboundSchema, ]), ).optional(), logprobs: z.array(LogProb$inboundSchema).optional(), }); /** @internal */ export type OutputText$Outbound = { type: "output_text"; text: string; annotations?: | Array< | FileCitation$Outbound | URLCitation$Outbound | ContainerFileCitation$Outbound | FilePath$Outbound > | undefined; logprobs?: Array | undefined; }; /** @internal */ export const OutputText$outboundSchema: z.ZodType< OutputText$Outbound, z.ZodTypeDef, OutputText > = z.object({ type: z.literal("output_text"), text: z.string(), annotations: z.array( z.union([ FileCitation$outboundSchema, URLCitation$outboundSchema, ContainerFileCitation$outboundSchema, FilePath$outboundSchema, ]), ).optional(), logprobs: z.array(LogProb$outboundSchema).optional(), }); export function outputTextToJSON(outputText: OutputText): string { return JSON.stringify(OutputText$outboundSchema.parse(outputText)); } export function outputTextFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OutputText$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OutputText' from JSON`, ); }