/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: fc94fa41530d */ 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 { ChatMessage, ChatMessage$inboundSchema } from "./chatmessage.js"; import { ChatMetadata, ChatMetadata$inboundSchema } from "./chatmetadata.js"; /** * A single response from the /chat backend. */ export type ChatResponse = { messages?: Array | undefined; /** * The id of the associated Chat the messages belong to, if one exists. */ chatId?: string | undefined; /** * Metadata of a Chat a user had with Glean Assistant. This contains no actual conversational content. */ chat?: ChatMetadata | undefined; /** * Follow-up prompts for the user to potentially use */ followUpPrompts?: Array | undefined; /** * Time in milliseconds the backend took to respond to the request. */ backendTimeMillis?: number | undefined; /** * A token that is used to track the session. */ chatSessionTrackingToken?: string | undefined; }; /** @internal */ export const ChatResponse$inboundSchema: z.ZodType< ChatResponse, z.ZodTypeDef, unknown > = z.object({ messages: z.array(ChatMessage$inboundSchema).optional(), chatId: z.string().optional(), chat: ChatMetadata$inboundSchema.optional(), followUpPrompts: z.array(z.string()).optional(), backendTimeMillis: z.number().int().optional(), chatSessionTrackingToken: z.string().optional(), }); export function chatResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatResponse' from JSON`, ); }