/* * 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 web URL in the model's output. Used when the model references information from web sources. */ export type URLCitation = { /** * The annotation type identifier for URL citations. */ type: "url_citation"; /** * The character index where the cited text ends in the output. */ endIndex: number; /** * The character index where the cited text begins in the output. */ startIndex: number; /** * The title of the web page or resource being cited. */ title: string; /** * The URL of the web resource being cited. */ url: string; }; /** @internal */ export const URLCitation$inboundSchema: z.ZodType< URLCitation, z.ZodTypeDef, unknown > = z.object({ type: z.literal("url_citation"), end_index: z.number().int(), start_index: z.number().int(), title: z.string(), url: z.string(), }).transform((v) => { return remap$(v, { "end_index": "endIndex", "start_index": "startIndex", }); }); /** @internal */ export type URLCitation$Outbound = { type: "url_citation"; end_index: number; start_index: number; title: string; url: string; }; /** @internal */ export const URLCitation$outboundSchema: z.ZodType< URLCitation$Outbound, z.ZodTypeDef, URLCitation > = z.object({ type: z.literal("url_citation"), endIndex: z.number().int(), startIndex: z.number().int(), title: z.string(), url: z.string(), }).transform((v) => { return remap$(v, { endIndex: "end_index", startIndex: "start_index", }); }); export function urlCitationToJSON(urlCitation: URLCitation): string { return JSON.stringify(URLCitation$outboundSchema.parse(urlCitation)); } export function urlCitationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => URLCitation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'URLCitation' from JSON`, ); }