/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CodeInterpreterOutput, CodeInterpreterOutput$inboundSchema, CodeInterpreterOutput$Outbound, CodeInterpreterOutput$outboundSchema, } from "./codeinterpreteroutput.js"; import { FileSearchOutput, FileSearchOutput$inboundSchema, FileSearchOutput$Outbound, FileSearchOutput$outboundSchema, } from "./filesearchoutput.js"; import { FinalAnswer, FinalAnswer$inboundSchema, FinalAnswer$Outbound, FinalAnswer$outboundSchema, } from "./finalanswer.js"; import { RagieApiSchemaResponseUsage, RagieApiSchemaResponseUsage$inboundSchema, RagieApiSchemaResponseUsage$Outbound, RagieApiSchemaResponseUsage$outboundSchema, } from "./ragieapischemaresponseusage.js"; import { Reasoning, Reasoning$inboundSchema, Reasoning$Outbound, Reasoning$outboundSchema, } from "./reasoning.js"; import { ReasoningOutput, ReasoningOutput$inboundSchema, ReasoningOutput$Outbound, ReasoningOutput$outboundSchema, } from "./reasoningoutput.js"; import { ResponseOutputMessage, ResponseOutputMessage$inboundSchema, ResponseOutputMessage$Outbound, ResponseOutputMessage$outboundSchema, } from "./responseoutputmessage.js"; import { Tool, Tool$inboundSchema, Tool$Outbound, Tool$outboundSchema, } from "./tool.js"; export const Status = { Completed: "completed", Failed: "failed", InProgress: "in_progress", Cancelled: "cancelled", } as const; export type Status = ClosedEnum; export type Output = | ReasoningOutput | CodeInterpreterOutput | FileSearchOutput | ResponseOutputMessage; export type ResponseT = { id: string; object?: "response" | undefined; createdAt: number; status: Status; error?: string | null | undefined; incompleteDetails?: any | null | undefined; instructions?: string | null | undefined; maxOutputTokens?: any | null | undefined; model?: "deep-search" | undefined; output: Array< | ReasoningOutput | CodeInterpreterOutput | FileSearchOutput | ResponseOutputMessage >; outputParsed?: FinalAnswer | null | undefined; tools: Array; reasoning: Reasoning; parallelToolCalls?: boolean | undefined; store?: boolean | undefined; temperature?: number | undefined; previousResponseId?: string | null | undefined; toolChoice?: "auto" | undefined; topP?: number | undefined; truncation?: "disabled" | undefined; usage: RagieApiSchemaResponseUsage; user?: any | null | undefined; metadata?: { [k: string]: any } | undefined; }; /** @internal */ export const Status$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Status); /** @internal */ export const Status$outboundSchema: z.ZodNativeEnum = Status$inboundSchema; /** @internal */ export const Output$inboundSchema: z.ZodType = z .union([ ReasoningOutput$inboundSchema, CodeInterpreterOutput$inboundSchema, FileSearchOutput$inboundSchema, ResponseOutputMessage$inboundSchema, ]); /** @internal */ export type Output$Outbound = | ReasoningOutput$Outbound | CodeInterpreterOutput$Outbound | FileSearchOutput$Outbound | ResponseOutputMessage$Outbound; /** @internal */ export const Output$outboundSchema: z.ZodType< Output$Outbound, z.ZodTypeDef, Output > = z.union([ ReasoningOutput$outboundSchema, CodeInterpreterOutput$outboundSchema, FileSearchOutput$outboundSchema, ResponseOutputMessage$outboundSchema, ]); export function outputToJSON(output: Output): string { return JSON.stringify(Output$outboundSchema.parse(output)); } export function outputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Output$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Output' from JSON`, ); } /** @internal */ export const ResponseT$inboundSchema: z.ZodType< ResponseT, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("response").default("response"), created_at: z.number().int(), status: Status$inboundSchema, error: z.nullable(z.string()).optional(), incomplete_details: z.nullable(z.any()).optional(), instructions: z.nullable(z.string()).optional(), max_output_tokens: z.nullable(z.any()).optional(), model: z.literal("deep-search").default("deep-search"), output: z.array( z.union([ ReasoningOutput$inboundSchema, CodeInterpreterOutput$inboundSchema, FileSearchOutput$inboundSchema, ResponseOutputMessage$inboundSchema, ]), ), output_parsed: z.nullable(FinalAnswer$inboundSchema).optional(), tools: z.array(Tool$inboundSchema), reasoning: Reasoning$inboundSchema, parallel_tool_calls: z.boolean().default(false), store: z.boolean().default(false), temperature: z.number().default(1), previous_response_id: z.nullable(z.string()).optional(), tool_choice: z.literal("auto").default("auto"), top_p: z.number().default(1), truncation: z.literal("disabled").default("disabled"), usage: RagieApiSchemaResponseUsage$inboundSchema, user: z.nullable(z.any()).optional(), metadata: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { "created_at": "createdAt", "incomplete_details": "incompleteDetails", "max_output_tokens": "maxOutputTokens", "output_parsed": "outputParsed", "parallel_tool_calls": "parallelToolCalls", "previous_response_id": "previousResponseId", "tool_choice": "toolChoice", "top_p": "topP", }); }); /** @internal */ export type ResponseT$Outbound = { id: string; object: "response"; created_at: number; status: string; error?: string | null | undefined; incomplete_details?: any | null | undefined; instructions?: string | null | undefined; max_output_tokens?: any | null | undefined; model: "deep-search"; output: Array< | ReasoningOutput$Outbound | CodeInterpreterOutput$Outbound | FileSearchOutput$Outbound | ResponseOutputMessage$Outbound >; output_parsed?: FinalAnswer$Outbound | null | undefined; tools: Array; reasoning: Reasoning$Outbound; parallel_tool_calls: boolean; store: boolean; temperature: number; previous_response_id?: string | null | undefined; tool_choice: "auto"; top_p: number; truncation: "disabled"; usage: RagieApiSchemaResponseUsage$Outbound; user?: any | null | undefined; metadata?: { [k: string]: any } | undefined; }; /** @internal */ export const ResponseT$outboundSchema: z.ZodType< ResponseT$Outbound, z.ZodTypeDef, ResponseT > = z.object({ id: z.string(), object: z.literal("response").default("response" as const), createdAt: z.number().int(), status: Status$outboundSchema, error: z.nullable(z.string()).optional(), incompleteDetails: z.nullable(z.any()).optional(), instructions: z.nullable(z.string()).optional(), maxOutputTokens: z.nullable(z.any()).optional(), model: z.literal("deep-search").default("deep-search" as const), output: z.array( z.union([ ReasoningOutput$outboundSchema, CodeInterpreterOutput$outboundSchema, FileSearchOutput$outboundSchema, ResponseOutputMessage$outboundSchema, ]), ), outputParsed: z.nullable(FinalAnswer$outboundSchema).optional(), tools: z.array(Tool$outboundSchema), reasoning: Reasoning$outboundSchema, parallelToolCalls: z.boolean().default(false), store: z.boolean().default(false), temperature: z.number().default(1), previousResponseId: z.nullable(z.string()).optional(), toolChoice: z.literal("auto").default("auto" as const), topP: z.number().default(1), truncation: z.literal("disabled").default("disabled" as const), usage: RagieApiSchemaResponseUsage$outboundSchema, user: z.nullable(z.any()).optional(), metadata: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { createdAt: "created_at", incompleteDetails: "incomplete_details", maxOutputTokens: "max_output_tokens", outputParsed: "output_parsed", parallelToolCalls: "parallel_tool_calls", previousResponseId: "previous_response_id", toolChoice: "tool_choice", topP: "top_p", }); }); export function responseToJSON(responseT: ResponseT): string { return JSON.stringify(ResponseT$outboundSchema.parse(responseT)); } export function responseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResponseT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseT' from JSON`, ); }