typescriptazure-openaiteams-toolkit

How to chain prompts in teams-ai version 1.0.0 (MS Teams AI Bot app)?


In @microsoft/teams-ai: ^0.1.0-preview.2 I used to use AI<ApplicationTurnState>.chain(context: TurnContext, state: ApplicationTurnState, prompt?: string | PromptTemplate, options?: Partial<AIOptions<ApplicationTurnState>>): Promise<...> Chains into another prompt and executes the plan that is returned..

Example:

await app.ai.chain(context, state, 'generateSomeDocument');

However in the new @microsoft/teams-ai: ^1.0.0 I cannot for the life of me find anything like that? The closest I've got is ActionPlanner<TurnState<DefaultConversationState, DefaultUserState, DefaultTempState>>.completePrompt<string>(context: TurnContext, memory: Memory, prompt: string | PromptTemplate, validator?: PromptResponseValidator<string>): Promise<...> Completes a prompt using an optional validator.

Example:

const response = await planner.completePrompt(context, state, 'generateSomeDocument');

Naturally, completePrompt only returns DO/SAY JSON object, whereas chain method used to return expected result from a prompt chained onto the main prompt.

I've looked at all the updated examples and couldn't see anything in regards of this functionality?

I think I've managed to address all the other breaking changes but this one.


Solution

  • It would seem I can use planner.completePrompt(context, state, 'generateSomeDocument') instead of chain(). It may be that the bug #1130 was throwing me off massively in my efforts or something changed slightly since teams-ai 1.3.