/* * 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"; import { SearchResultLink, SearchResultLink$inboundSchema, SearchResultLink$Outbound, SearchResultLink$outboundSchema, } from "./searchresultlink.js"; export type RagieEvidence = { type?: "ragie" | undefined; text: string; /** * The chunk id of the evidence. */ id: string; /** * The index of the chunk in the document. */ index: number; /** * The document id of the document containing the chunk being used as evidence. */ documentId: string; /** * The name of the document that contains the chunk being used as evidence. */ documentName: string; /** * The metadata of the chunk being used as evidence. */ metadata?: { [k: string]: any } | undefined; /** * The metadata of the document that contains the evidence. */ documentMetadata?: { [k: string]: any } | undefined; /** * The links to the evidence. */ links?: { [k: string]: SearchResultLink } | undefined; }; /** @internal */ export const RagieEvidence$inboundSchema: z.ZodType< RagieEvidence, z.ZodTypeDef, unknown > = z.object({ type: z.literal("ragie").default("ragie"), text: z.string(), id: z.string(), index: z.number().int(), document_id: z.string(), document_name: z.string(), metadata: z.record(z.any()).optional(), document_metadata: z.record(z.any()).optional(), links: z.record(SearchResultLink$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "document_id": "documentId", "document_name": "documentName", "document_metadata": "documentMetadata", }); }); /** @internal */ export type RagieEvidence$Outbound = { type: "ragie"; text: string; id: string; index: number; document_id: string; document_name: string; metadata?: { [k: string]: any } | undefined; document_metadata?: { [k: string]: any } | undefined; links?: { [k: string]: SearchResultLink$Outbound } | undefined; }; /** @internal */ export const RagieEvidence$outboundSchema: z.ZodType< RagieEvidence$Outbound, z.ZodTypeDef, RagieEvidence > = z.object({ type: z.literal("ragie").default("ragie" as const), text: z.string(), id: z.string(), index: z.number().int(), documentId: z.string(), documentName: z.string(), metadata: z.record(z.any()).optional(), documentMetadata: z.record(z.any()).optional(), links: z.record(SearchResultLink$outboundSchema).optional(), }).transform((v) => { return remap$(v, { documentId: "document_id", documentName: "document_name", documentMetadata: "document_metadata", }); }); export function ragieEvidenceToJSON(ragieEvidence: RagieEvidence): string { return JSON.stringify(RagieEvidence$outboundSchema.parse(ragieEvidence)); } export function ragieEvidenceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RagieEvidence$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RagieEvidence' from JSON`, ); }