/** * OpenAI Chat Completions wire shapes, as Databricks Model Serving speaks them. * * These are the request/reply payload types for `/chat/completions` and a * serving endpoint's `invocations` URL. They are deliberately declared here * rather than imported from the OpenAI or AI SDK packages: both keep these * fields under internal namespaces that are not part of their public API, * whereas the wire payload itself is the stable contract every caller in this * repo actually codes against. * * @module */ import { z } from "zod"; export declare const ChatRoleSchema: z.ZodEnum<{ system: "system"; developer: "developer"; user: "user"; assistant: "assistant"; tool: "tool"; }>; export type ChatRole = z.infer; export declare const ChatContentPartSchema: z.ZodObject<{ type: z.ZodOptional; text: z.ZodOptional; }, z.core.$catchall>; export type ChatContentPart = z.infer; export declare const ChatToolCallFunctionSchema: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, z.core.$strip>; export type ChatToolCallFunction = z.infer; export declare const ChatToolCallSchema: z.ZodObject<{ id: z.ZodString; type: z.ZodString; function: z.ZodObject<{ name: z.ZodString; arguments: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; export type ChatToolCall = z.infer; export declare const ChatMessageSchema: z.ZodObject<{ role: z.ZodString; content: z.ZodOptional; text: z.ZodOptional; }, z.core.$catchall>, z.ZodArray; text: z.ZodOptional; }, z.core.$catchall>>]>>>; tool_calls: z.ZodOptional; }, z.core.$strip>>>; tool_call_id: z.ZodOptional; name: z.ZodOptional; }, z.core.$strip>; export type ChatMessage = z.infer; /** * Top-level request fields an OpenAI client may send that Databricks Model * Serving rejects outright, failing the whole turn rather than ignoring them. * * Databricks validates the chat body strictly, so an unrecognized key comes * back as `parallel_tool_calls: Extra inputs are not permitted` (the * gateway's pydantic validation) or `json: unknown field "parallel_tool_calls"` * (its strict JSON decode), depending on the endpoint. Everything listed here * is either OpenAI-platform bookkeeping with no bearing on the completion, or - * in the case of `parallel_tool_calls` - a real setting Databricks has no way * to accept, so dropping it is the only way the request can succeed at all. * * Callers that translate a request field-by-field through an allowlist never * need this; it exists for the * paths that forward a client body largely as-is. */ export declare const UNSUPPORTED_CHAT_FIELDS: readonly string[]; /** * Delete the fields Databricks rejects from a chat request body, in place. * Returns the names actually removed so a caller can log what it dropped. * * @param body - Parsed chat request body. Mutated. * @param extra - Additional field names to drop, for a workspace or endpoint * that rejects something not yet in {@link UNSUPPORTED_CHAT_FIELDS}. */ export declare function stripUnsupportedChatFields(body: Record, extra?: readonly string[]): string[]; export declare const ChatContentToTextOptionsSchema: z.ZodObject<{ separator: z.ZodOptional; types: z.ZodOptional>; }, z.core.$strip>; export type ChatContentToTextOptions = z.infer; /** * Normalize structured chat content to an array. Providers usually emit a * parts array, but some compatibility layers collapse a one-part array to the * object itself. Returns `undefined` for strings, nulls, and other scalar * values so callers can distinguish structured content from plain text. */ export declare function chatContentParts(content: unknown): ChatContentPart[] | undefined; /** * Flatten a message `content` value to plain text. Accepts the string form and * structured content as either one {@link ChatContentPart} or an array, and * yields `""` for anything else (null, a lone image part, a malformed payload). * Typed as `unknown` because most callers are reading a just-parsed JSON body, * and the point of this helper is that they do not have to pre-check it. */ export declare function chatContentToText(content: unknown, options?: ChatContentToTextOptions): string;