@microsoft/teams-ai
Version:
SDK focused on building AI based applications for Microsoft Teams.
48 lines • 2.31 kB
TypeScript
import { TurnContext } from 'botbuilder';
import { Schema } from 'jsonschema';
import { Memory } from '../MemoryFork';
import { Validation, PromptResponseValidator } from './PromptResponseValidator';
import { Tokenizer } from '../tokenizers';
import { PromptResponse } from '../types';
/**
* Parses any JSON returned by the model and optionally verifies it against a JSON schema.
* @template TValue Optional. Type of the validation value returned. Defaults to `Record<string, any>`.
*/
export declare class JSONResponseValidator<TValue = Record<string, any>> implements PromptResponseValidator<TValue> {
/**
* Creates a new `JSONResponseValidator` instance.
* @param {Schema} schema Optional. JSON schema to validate the response against.
* @param {string} missingJsonFeedback Optional. Custom feedback to give when no JSON is returned.
* @param {string} errorFeedback Optional. Custom feedback prefix to use when schema errors are detected.
*/
constructor(schema?: Schema, missingJsonFeedback?: string, errorFeedback?: string);
/**
* Feedback prefix given when schema errors are detected.
*/
errorFeedback: string;
/**
* Feedback given when no JSON is returned.
*/
missingJsonFeedback: string;
/**
* JSON schema to validate the response against.
*/
readonly schema?: Schema;
/**
* Validates a response to a prompt.
* @param {TurnContext} context Context for the current turn of conversation with the user.
* @param {Memory} memory An interface for accessing state values.
* @param {Tokenizer} tokenizer Tokenizer to use for encoding and decoding text.
* @param {PromptResponse<string>} response Response to validate.
* @param {number} remaining_attempts Number of remaining attempts to validate the response.
* @returns {Promise<Validation<TValue>>} A `Validation` object.
*/
validateResponse(context: TurnContext, memory: Memory, tokenizer: Tokenizer, response: PromptResponse<string>, remaining_attempts: number): Promise<Validation<TValue>>;
/**
* @private
* @param {ValidationError} error Error in the JSON object
* @returns {string} How to fix the given error.
*/
private getErrorFix;
}
//# sourceMappingURL=JSONResponseValidator.d.ts.map