@genkit-ai/dotprompt
Version:
Genkit AI framework `.prompt` file format and management library.
97 lines (93 loc) • 3.27 kB
text/typescript
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';
import '@genkit-ai/core/registry';
import '@genkit-ai/core/schema';
/**
* 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[];
messages?: MessageData[];
}, data?: Record<string, any>) => {
content: ({
media: {
url: string;
contentType?: string | undefined;
};
text?: undefined;
custom?: Record<string, unknown> | undefined;
metadata?: Record<string, unknown> | undefined;
toolRequest?: undefined;
toolResponse?: undefined;
data?: unknown;
} | {
text: string;
media?: undefined;
custom?: Record<string, unknown> | undefined;
metadata?: Record<string, unknown> | undefined;
toolRequest?: undefined;
toolResponse?: undefined;
data?: unknown;
} | {
toolRequest: {
name: string;
input?: unknown;
ref?: string | undefined;
};
text?: undefined;
media?: undefined;
custom?: Record<string, unknown> | undefined;
metadata?: Record<string, unknown> | undefined;
toolResponse?: undefined;
data?: unknown;
} | {
toolResponse: {
name: string;
output?: unknown;
ref?: string | undefined;
};
text?: undefined;
media?: undefined;
custom?: Record<string, unknown> | undefined;
metadata?: Record<string, unknown> | undefined;
toolRequest?: undefined;
data?: unknown;
} | {
text?: undefined;
media?: undefined;
custom?: Record<string, unknown> | undefined;
metadata?: Record<string, unknown> | undefined;
toolRequest?: undefined;
toolResponse?: undefined;
data?: unknown;
} | {
custom: Record<string, any>;
text?: undefined;
media?: undefined;
metadata?: Record<string, unknown> | undefined;
toolRequest?: undefined;
toolResponse?: undefined;
data?: unknown;
})[];
role: "model" | "system" | "tool" | "user";
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 };