/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Annotation for citing a specific file in the model's output. Used when the model references information from a file. */ export type FileCitation = { /** * The annotation type identifier for file citations. */ type: "file_citation"; /** * The ID of the file being cited. */ fileId: string; /** * The name of the file being cited. */ filename: string; /** * The character index in the output text where this citation applies. */ index: number; }; /** @internal */ export const FileCitation$inboundSchema: z.ZodType< FileCitation, z.ZodTypeDef, unknown > = z.object({ type: z.literal("file_citation"), file_id: z.string(), filename: z.string(), index: z.number().int(), }).transform((v) => { return remap$(v, { "file_id": "fileId", }); }); /** @internal */ export type FileCitation$Outbound = { type: "file_citation"; file_id: string; filename: string; index: number; }; /** @internal */ export const FileCitation$outboundSchema: z.ZodType< FileCitation$Outbound, z.ZodTypeDef, FileCitation > = z.object({ type: z.literal("file_citation"), fileId: z.string(), filename: z.string(), index: z.number().int(), }).transform((v) => { return remap$(v, { fileId: "file_id", }); }); export function fileCitationToJSON(fileCitation: FileCitation): string { return JSON.stringify(FileCitation$outboundSchema.parse(fileCitation)); } export function fileCitationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FileCitation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileCitation' from JSON`, ); }