Skip to content

Commit

Permalink
fix: Add AI disclaimer to Teams extension (#1074)
Browse files Browse the repository at this point in the history
Co-authored-by: Rohini-Microsoft <v-rwalunj@microsoft.com>
  • Loading branch information
Prasanjeet-Microsoft and Rohini-Microsoft authored Jun 21, 2024
1 parent 016489b commit 2efccd1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion extensions/teams/cards/cardBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export function cardBodyBuilder(citations: any[], assistantAnswer: string): any
}, {
type: 'ActionSet',
actions: []
}, {
type: CardType.TextBlock,
text: "AI-generated content may be incorrect",
wrap: true,
weight: "lighter",
size: "small",
color: "default"
}
],
actions: [],
Expand Down Expand Up @@ -109,4 +116,4 @@ export function cwydResponseBuilder(citations: Citation[], assistantAnswer: stri
assistantAnswer = assistantAnswer.replaceAll(deleteEndSpace, "");
let answerCard = CardFactory.adaptiveCard(cardBodyBuilder(citationActions, assistantAnswer));
return answerCard;
}
}
8 changes: 5 additions & 3 deletions extensions/teams/teamsBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class TeamsBot extends TeamsActivityHandler {
super();
let newActivity;
let assistantAnswer = "";
let answerwithdisclaimertext = "";
let activityUpdated = true;

this.onMessage(async (context, next) => {
Expand Down Expand Up @@ -118,13 +119,14 @@ export class TeamsBot extends TeamsActivityHandler {
answers.map((answer, index) => {
if (answer.role === "assistant") {
assistantAnswer = answer.content;
answerwithdisclaimertext = assistantAnswer + "<div style='color:#707070;font-size:12px;font-family: Segoe UI;font-style: normal;font-weight: 400; line-height: 16px; margin-top: 15px; padding-bottom: 5px;'>AI-generated content may be incorrect</div>" ;
if (assistantAnswer.startsWith("[doc")) {
assistantAnswer = EMPTY_RESPONSE;
newActivity = MessageFactory.text(assistantAnswer);
newActivity = MessageFactory.text(answerwithdisclaimertext);
} else {
const citations = parseCitationFromMessage(answers[index - 1]) as Citation[];
if (citations.length === 0) {
newActivity = MessageFactory.text(assistantAnswer);
newActivity = MessageFactory.text(answerwithdisclaimertext);
newActivity.id = reply.id;
} else {
newActivity = MessageFactory.attachment(cwydResponseBuilder(citations, assistantAnswer));
Expand Down Expand Up @@ -175,4 +177,4 @@ export class TeamsBot extends TeamsActivityHandler {
await next();
});
}
}
}

0 comments on commit 2efccd1

Please sign in to comment.