Open asith-w opened 1 week ago
The format of this response is controlled through the handler class-
For TwentyQuestions, your circled area is captured here
You can see our use of adaptive cards in the TypeAhead sample's ActivityHandler class, you can use the message factory class to send an attachment instead of a text string
@lilyydu Thank your reply it was relay helpful.
In that case, I believe I should use the code below to manually get an AI response by registering OnActivity activity handler
PromptResponse response = await _actionPlanner.CompletePromptAsync(turnContext, turnState, template, null, cancellationToken);
Hi @asith-w,
You won't be calling that method in particular (thats used internally in our library), instead you will need to create your own custom activity handler-
Example of replacing the TwentyQuestionBot's handler with the logic from TypeAheadBot
public async Task OnMessageActivityAsync(ITurnContext turnContext, GameState turnState, CancellationToken cancellationToken)
{
Attachment attachment = CreateAdaptiveCardAttachment(_pathToAdaptiveCard);
await turnContext.SendActivityAsync(MessageFactory.Attachment(attachment), cancellationToken);
};
You can use the TurnState object to access specific parameters.
We also have a variety of handlers you can choose to override.
For TwentyQuestions specifically, the handlers are registered here (108-111)
Hi @lilyydu
this handlers link is not accessible for me
just to clear the answer again.
Here, what I tried
I created AI Chatbot template using visual studio toolkit and run the app once I ask a question from the bot , it responses with text answer in Teams I want to show this response text in a adaptive card , can I do it without manually calling _actionPlanner.CompletePromptAsync ()
or can i track AI response text before it sending activity something like this ?
app.OnActivity("AIPromptCompleted" , async (ITurnContext turnContext, TurnState turnState, CancellationToken cancellationToken) =>
{
var promptResponseText = GetPromptResponseText (...);
await turnContext.SendActivityAsync(MessageFactory.Attachment(GetCardAttachment(promptResponseText )), cancellationToken);
});
Hi @asith-w,
My apologies, I pasted in the wrong link and misunderstood your question. First, could you try here
If you want to manually get a response from the LLM, you can call CompletePromptAsync
. In the example of TwentyQuestions
, you can replace L71 with
Attachment attachment = CreateAdaptiveCardAttachment(_pathToAdaptiveCard, guessCount, hint);
await turnContext.SendActivityAsync(MessageFactory.Attachment(attachment), cancellationToken);
Extra data generated from the LLM can be passed through as method parameters.
If you do have a specific scenario in mind, you can utilize actions as well, the LightBot is a good example of this
Could you attach the link to the AI Chatbot you are using so I could also give you more specific assistance?
Question
I am trying to modify the AI response from text to an adaptive card.
For example, in the dotnet 04.e.twentyQuestions sample project, when a user asks a question, it currently provides a text answer. Instead, how can I alter the AI response to return an adaptive card? such as below image ,
should i use output Moderator or something?