@microsoft/teams-ai
Version:
SDK focused on building AI based applications for Microsoft Teams.
109 lines • 4.77 kB
TypeScript
/**
* @module teams-ai
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { Message } from './Message';
import { PromptFunctions } from './PromptFunctions';
import { RenderedPromptSection, PromptSection } from './PromptSection';
import { TurnContext } from 'botbuilder';
import { Tokenizer } from '../tokenizers';
import { Memory } from '../MemoryFork';
/**
* Base layout engine that renders a set of `auto`, `fixed`, or `proportional` length sections.
* @remarks
* This class is used internally by the `Prompt` and `GroupSection` classes to render their sections.
*/
export declare class LayoutEngine implements PromptSection {
readonly sections: PromptSection[];
readonly required: boolean;
readonly tokens: number;
readonly separator: string;
/**
*
* @param {PromptSection[]} sections List of sections to layout.
* @param {number} tokens Sizing strategy for this section.
* @param {boolean} required Indicates if this section is required.
* @param {string} separator Separator to use between sections when rendering as text.
*/
constructor(sections: PromptSection[], tokens: number, required: boolean, separator: string);
/**
* @private
* @param {TurnContext} context Context for the current turn of conversation with the user.
* @param {Memory} memory The current memory.
* @param {PromptFunctions} functions The functions available to use in the prompt.
* @param {Tokenizer} tokenizer Tokenizer to use when rendering as text.
* @param {number} maxTokens Maximum number of tokens allowed.
* @returns {Promise<RenderedPromptSection<string>>} Rendered section.
*/
renderAsText(context: TurnContext, memory: Memory, functions: PromptFunctions, tokenizer: Tokenizer, maxTokens: number): Promise<RenderedPromptSection<string>>;
/**
* @private
* @param {TurnContext} context Context for the current turn of conversation with the user.
* @param {Memory} memory The current memory.
* @param {PromptFunctions} functions The functions available to use in the prompt.
* @param {Tokenizer} tokenizer Tokenizer to use when rendering as text.
* @param {number} maxTokens Maximum number of tokens allowed.
* @returns {Promise<RenderedPromptSection<Message[]>>} Rendered section.
*/
renderAsMessages(context: TurnContext, memory: Memory, functions: PromptFunctions, tokenizer: Tokenizer, maxTokens: number): Promise<RenderedPromptSection<Message[]>>;
/**
* @private
* @template T
* @param {PromptSection[]} sections Sections to add to the layout.
* @param {PromptSectionLayout<T>[]} layout Layout to add the sections to.
*/
private addSectionsToLayout;
/**
* @private
* @template T
* @param {PromptSectionLayout<T>[]} layout Layout to render.
* @param {number} maxTokens Maximum number of tokens allowed.
* @param {Function} cbFixed Callback to render a fixed section.
* @param {Function} cbProportional Callback to render a proportional section.
* @param {boolean} textLayout Indicates if the layout is being rendered as text.
* @param {Tokenizer} tokenizer Tokenizer to use when rendering as text.
* @returns {Promise<number>} Number of tokens remaining.
*/
private layoutSections;
/**
* @private
* @template T
* @param {PromptSectionLayout<T>[]} layout Layout to render.
* @param {Function} callback Callback to render a fixed section of the layout.
*/
private layoutFixedSections;
/**
* @private
* @template T
* @param {PromptSectionLayout<T>[]} layout Layout to render.
* @param {Function} callback Callback to render a proportional section of the layout.
*/
private layoutProportionalSections;
/**
* @private
* @template T
* @param {PromptSectionLayout<T>[]} layout Layout to get the length of.
* @param {boolean} textLayout Indicates if the layout is being rendered as text.
* @param {Tokenizer} tokenizer Tokenizer to use when rendering as text.
* @returns {number} Length of the layout.
*/
private getLayoutLength;
/**
* @private
* @template T
* @param {PromptSectionLayout<T>[]} layout Layout to drop the last optional section from.
* @returns {boolean} True if an optional section was dropped, false otherwise.
*/
private dropLastOptionalSection;
/**
* @private
* @template T
* @param {PromptSectionLayout<T>[]} layout Layout to check.
* @returns {boolean} True if the layout needs more rendering, false otherwise.
*/
private needsMoreLayout;
}
//# sourceMappingURL=LayoutEngine.d.ts.map