Skip to content

fix: Add AI disclaimer to Teams extension #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
}
}
}
Loading