UNPKG

@genkit-ai/dotprompt

Version:

Genkit AI framework `.prompt` file format and management library.

96 lines (92 loc) 3.19 kB
import { MessageData } from '@genkit-ai/ai/model'; import { DocumentData } from '@genkit-ai/ai/retriever'; import Handlebars from 'handlebars'; import { PromptMetadata } from './metadata.mjs'; import '@genkit-ai/ai/tool'; import '@genkit-ai/core/schema'; import 'zod'; /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ declare function compile<Variables = any>(source: string, metadata: PromptMetadata): (input: Variables, options?: { context?: DocumentData[]; history?: MessageData[]; }) => { role: "model" | "tool" | "user" | "system"; content: ({ text: string; data?: unknown; custom?: Record<string, unknown> | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; metadata?: Record<string, unknown> | undefined; } | { media: { url: string; contentType?: string | undefined; }; data?: unknown; custom?: Record<string, unknown> | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; metadata?: Record<string, unknown> | undefined; } | { toolRequest: { name: string; ref?: string | undefined; input?: unknown; }; data?: unknown; custom?: Record<string, unknown> | undefined; text?: undefined; media?: undefined; toolResponse?: undefined; metadata?: Record<string, unknown> | undefined; } | { toolResponse: { name: string; ref?: string | undefined; output?: unknown; }; data?: unknown; custom?: Record<string, unknown> | undefined; text?: undefined; media?: undefined; toolRequest?: undefined; metadata?: Record<string, unknown> | undefined; } | { custom?: Record<string, unknown> | undefined; text?: undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; metadata?: Record<string, unknown> | undefined; data?: unknown; } | { custom: Record<string, any>; data?: unknown; text?: undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; metadata?: Record<string, unknown> | undefined; })[]; metadata?: Record<string, unknown> | undefined; }[]; declare function defineHelper(name: string, fn: Handlebars.HelperDelegate): void; declare function definePartial(name: string, source: string): void; export { compile, defineHelper, definePartial };