import { z, Action } from '@genkit-ai/core'; import { Registry } from '@genkit-ai/core/registry'; import { b as DocumentData, D as Document, h as EmbedderInfo } from './document-Batw8a-E.js'; export { a as DocumentDataSchema, M as MediaPart, P as Part, n as TextPart } from './document-Batw8a-E.js'; /** * 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. */ /** * Retriever implementation function signature. */ type RetrieverFn = (query: Document, queryOpts: z.infer) => Promise; /** * Indexer implementation function signature. */ type IndexerFn = (docs: Array, indexerOpts: z.infer) => Promise; declare const RetrieverRequestSchema: z.ZodObject<{ query: z.ZodObject<{ content: z.ZodArray; toolRequest: z.ZodOptional; toolResponse: z.ZodOptional; data: z.ZodOptional; metadata: z.ZodOptional>; custom: z.ZodOptional>; reasoning: z.ZodOptional; resource: z.ZodOptional; } & { text: z.ZodString; }, "strip", z.ZodTypeAny, { text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }, { text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }>, z.ZodObject<{ text: z.ZodOptional; toolRequest: z.ZodOptional; toolResponse: z.ZodOptional; data: z.ZodOptional; metadata: z.ZodOptional>; custom: z.ZodOptional>; reasoning: z.ZodOptional; resource: z.ZodOptional; } & { media: z.ZodObject<{ contentType: z.ZodOptional; url: z.ZodString; }, "strip", z.ZodTypeAny, { url: string; contentType?: string | undefined; }, { url: string; contentType?: string | undefined; }>; }, "strip", z.ZodTypeAny, { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }, { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }>]>, "many">; metadata: z.ZodOptional>; }, "strip", z.ZodTypeAny, { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }, { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }>; options: z.ZodOptional; }, "strip", z.ZodTypeAny, { query: { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }; options?: any; }, { query: { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }; options?: any; }>; declare const RetrieverResponseSchema: z.ZodObject<{ documents: z.ZodArray; toolRequest: z.ZodOptional; toolResponse: z.ZodOptional; data: z.ZodOptional; metadata: z.ZodOptional>; custom: z.ZodOptional>; reasoning: z.ZodOptional; resource: z.ZodOptional; } & { text: z.ZodString; }, "strip", z.ZodTypeAny, { text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }, { text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }>, z.ZodObject<{ text: z.ZodOptional; toolRequest: z.ZodOptional; toolResponse: z.ZodOptional; data: z.ZodOptional; metadata: z.ZodOptional>; custom: z.ZodOptional>; reasoning: z.ZodOptional; resource: z.ZodOptional; } & { media: z.ZodObject<{ contentType: z.ZodOptional; url: z.ZodString; }, "strip", z.ZodTypeAny, { url: string; contentType?: string | undefined; }, { url: string; contentType?: string | undefined; }>; }, "strip", z.ZodTypeAny, { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }, { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }>]>, "many">; metadata: z.ZodOptional>; }, "strip", z.ZodTypeAny, { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }, { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { documents: { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }[]; }, { documents: { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }[]; }>; type RetrieverResponse = z.infer; declare const IndexerRequestSchema: z.ZodObject<{ documents: z.ZodArray; toolRequest: z.ZodOptional; toolResponse: z.ZodOptional; data: z.ZodOptional; metadata: z.ZodOptional>; custom: z.ZodOptional>; reasoning: z.ZodOptional; resource: z.ZodOptional; } & { text: z.ZodString; }, "strip", z.ZodTypeAny, { text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }, { text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }>, z.ZodObject<{ text: z.ZodOptional; toolRequest: z.ZodOptional; toolResponse: z.ZodOptional; data: z.ZodOptional; metadata: z.ZodOptional>; custom: z.ZodOptional>; reasoning: z.ZodOptional; resource: z.ZodOptional; } & { media: z.ZodObject<{ contentType: z.ZodOptional; url: z.ZodString; }, "strip", z.ZodTypeAny, { url: string; contentType?: string | undefined; }, { url: string; contentType?: string | undefined; }>; }, "strip", z.ZodTypeAny, { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }, { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; }>]>, "many">; metadata: z.ZodOptional>; }, "strip", z.ZodTypeAny, { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }, { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }>, "many">; options: z.ZodOptional; }, "strip", z.ZodTypeAny, { documents: { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }[]; options?: any; }, { documents: { content: ({ text: string; custom?: Record | undefined; metadata?: Record | undefined; media?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; } | { media: { url: string; contentType?: string | undefined; }; custom?: Record | undefined; metadata?: Record | undefined; text?: undefined; toolRequest?: undefined; toolResponse?: undefined; data?: unknown; reasoning?: undefined; resource?: undefined; })[]; metadata?: Record | undefined; }[]; options?: any; }>; /** * Zod schema of retriever info metadata. */ declare const RetrieverInfoSchema: z.ZodObject<{ label: z.ZodOptional; /** Supported model capabilities. */ supports: z.ZodOptional; }, "strip", z.ZodTypeAny, { media?: boolean | undefined; }, { media?: boolean | undefined; }>>; }, "strip", z.ZodTypeAny, { label?: string | undefined; supports?: { media?: boolean | undefined; } | undefined; }, { label?: string | undefined; supports?: { media?: boolean | undefined; } | undefined; }>; type RetrieverInfo = z.infer; /** * A retriever action type. */ type RetrieverAction = Action & { __configSchema?: CustomOptions; }; /** * An indexer action type. */ type IndexerAction = Action & { __configSchema?: IndexerOptions; }; /** * Creates a retriever action for the provided {@link RetrieverFn} implementation. */ declare function defineRetriever(registry: Registry, options: { name: string; configSchema?: OptionsType; info?: RetrieverInfo; }, runner: RetrieverFn): RetrieverAction; /** * Creates an indexer action for the provided {@link IndexerFn} implementation. */ declare function defineIndexer(registry: Registry, options: { name: string; embedderInfo?: EmbedderInfo; configSchema?: IndexerOptions; }, runner: IndexerFn): IndexerAction; interface RetrieverParams { retriever: RetrieverArgument; query: string | DocumentData; options?: z.infer; } /** * A type that can be used to pass a retriever as an argument, either using a reference or an action. */ type RetrieverArgument = RetrieverAction | RetrieverReference | string; /** * Retrieves documents from a {@link RetrieverArgument} based on the provided query. */ declare function retrieve(registry: Registry, params: RetrieverParams): Promise>; /** * A type that can be used to pass an indexer as an argument, either using a reference or an action. */ type IndexerArgument = IndexerReference | IndexerAction | string; /** * Options passed to the index function. */ interface IndexerParams { indexer: IndexerArgument; documents: Array; options?: z.infer; } /** * Indexes documents using a {@link IndexerArgument}. */ declare function index(registry: Registry, params: IndexerParams): Promise; /** * Zod schema of common retriever options. */ declare const CommonRetrieverOptionsSchema: z.ZodObject<{ k: z.ZodOptional; }, "strip", z.ZodTypeAny, { k?: number | undefined; }, { k?: number | undefined; }>; /** * A retriver reference object. */ interface RetrieverReference { name: string; configSchema?: CustomOptions; info?: RetrieverInfo; } /** * Helper method to configure a {@link RetrieverReference} to a plugin. */ declare function retrieverRef(options: RetrieverReference): RetrieverReference; declare const IndexerInfoSchema: z.ZodObject<{ label: z.ZodOptional; /** Supported model capabilities. */ supports: z.ZodOptional; }, "strip", z.ZodTypeAny, { media?: boolean | undefined; }, { media?: boolean | undefined; }>>; }, "strip", z.ZodTypeAny, { label?: string | undefined; supports?: { media?: boolean | undefined; } | undefined; }, { label?: string | undefined; supports?: { media?: boolean | undefined; } | undefined; }>; /** * Indexer metadata. */ type IndexerInfo = z.infer; interface IndexerReference { name: string; configSchema?: CustomOptions; info?: IndexerInfo; } /** * Helper method to configure a {@link IndexerReference} to a plugin. */ declare function indexerRef(options: IndexerReference): IndexerReference; /** * Simple retriever options. */ interface SimpleRetrieverOptions { /** The name of the retriever you're creating. */ name: string; /** A Zod schema containing any configuration info available beyond the query. */ configSchema?: C; /** * Specifies how to extract content from the returned items. * * - If a string, specifies the key of the returned item to extract as content. * - If a function, allows you to extract content as text or a document part. **/ content?: string | ((item: R) => Document['content'] | string); /** * Specifies how to extract metadata from the returned items. * * - If an array of strings, specifies list of keys to extract from returned objects. * - If a function, allows you to use custom behavior to extract metadata from returned items. */ metadata?: string[] | ((item: R) => Document['metadata']); } /** * defineSimpleRetriever makes it easy to map existing data into documents that * can be used for prompt augmentation. * * @param options Configuration options for the retriever. * @param handler A function that queries a datastore and returns items from which to extract documents. * @returns A Genkit retriever. */ declare function defineSimpleRetriever(registry: Registry, options: SimpleRetrieverOptions, handler: (query: Document, config: z.infer) => Promise): RetrieverAction; export { CommonRetrieverOptionsSchema, Document, DocumentData, type IndexerAction, type IndexerArgument, type IndexerFn, type IndexerInfo, IndexerInfoSchema, type IndexerParams, type IndexerReference, type RetrieverAction, type RetrieverArgument, type RetrieverFn, type RetrieverInfo, RetrieverInfoSchema, type RetrieverParams, type RetrieverReference, type SimpleRetrieverOptions, defineIndexer, defineRetriever, defineSimpleRetriever, index, indexerRef, retrieve, retrieverRef };