UNPKG

@genkit-ai/ai

Version:

Genkit AI framework generative AI APIs.

128 lines 4.95 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var parts_exports = {}; __export(parts_exports, { CustomPartSchema: () => CustomPartSchema, DataPartSchema: () => DataPartSchema, MediaPartSchema: () => MediaPartSchema, MediaSchema: () => MediaSchema, MultipartToolResponseSchema: () => MultipartToolResponseSchema, PartSchema: () => PartSchema, ReasoningPartSchema: () => ReasoningPartSchema, ResourcePartSchema: () => ResourcePartSchema, TextPartSchema: () => TextPartSchema, ToolRequestPartSchema: () => ToolRequestPartSchema, ToolRequestSchema: () => ToolRequestSchema, ToolResponsePartSchema: () => ToolResponsePartSchema, ToolResponseSchema: () => ToolResponseSchema }); module.exports = __toCommonJS(parts_exports); var import_core = require("@genkit-ai/core"); const EmptyPartSchema = import_core.z.object({ text: import_core.z.never().optional(), media: import_core.z.never().optional(), toolRequest: import_core.z.never().optional(), toolResponse: import_core.z.never().optional(), data: import_core.z.unknown().optional(), metadata: import_core.z.record(import_core.z.unknown()).optional(), custom: import_core.z.record(import_core.z.unknown()).optional(), reasoning: import_core.z.never().optional(), resource: import_core.z.never().optional() }); const TextPartSchema = EmptyPartSchema.extend({ /** The text of the message. */ text: import_core.z.string() }); const ReasoningPartSchema = EmptyPartSchema.extend({ /** The reasoning text of the message. */ reasoning: import_core.z.string() }); const MediaSchema = import_core.z.object({ /** The media content type. Inferred from data uri if not provided. */ contentType: import_core.z.string().optional(), /** A `data:` or `https:` uri containing the media content. */ url: import_core.z.string() }); const MediaPartSchema = EmptyPartSchema.extend({ media: MediaSchema }); const ToolRequestSchema = import_core.z.object({ /** The call id or reference for a specific request. */ ref: import_core.z.string().optional(), /** The name of the tool to call. */ name: import_core.z.string(), /** The input parameters for the tool, usually a JSON object. */ input: import_core.z.unknown().optional(), /** Whether the request is a partial chunk. */ partial: import_core.z.boolean().optional() }); const ToolRequestPartSchema = EmptyPartSchema.extend({ /** A request for a tool to be executed, usually provided by a model. */ toolRequest: ToolRequestSchema }); const ToolResponseSchemaBase = import_core.z.object({ /** The call id or reference for a specific request. */ ref: import_core.z.string().optional(), /** The name of the tool. */ name: import_core.z.string(), /** The output data returned from the tool, usually a JSON object. */ output: import_core.z.unknown().optional() }); const ToolResponseSchema = ToolResponseSchemaBase.extend({ content: import_core.z.array(import_core.z.any()).optional() // TODO: switch to this once we have effective recursive schema support across the board. // content: z.array(z.lazy(() => PartSchema)).optional(), }); const ToolResponsePartSchema = EmptyPartSchema.extend({ /** A provided response to a tool call. */ toolResponse: ToolResponseSchema }); const DataPartSchema = EmptyPartSchema.extend({ data: import_core.z.unknown() }); const CustomPartSchema = EmptyPartSchema.extend({ custom: import_core.z.record(import_core.z.any()) }); const ResourcePartSchema = EmptyPartSchema.extend({ resource: import_core.z.object({ uri: import_core.z.string() }) }); const PartSchema = import_core.z.union([TextPartSchema, MediaPartSchema]); const MultipartToolResponseSchema = import_core.z.object({ output: import_core.z.unknown().optional(), content: import_core.z.array(PartSchema).optional() }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { CustomPartSchema, DataPartSchema, MediaPartSchema, MediaSchema, MultipartToolResponseSchema, PartSchema, ReasoningPartSchema, ResourcePartSchema, TextPartSchema, ToolRequestPartSchema, ToolRequestSchema, ToolResponsePartSchema, ToolResponseSchema }); //# sourceMappingURL=parts.js.map