Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
KI-Antworten beinhalten häufig Zitations- und Rückmeldungskontrollen. Eine KI-Engine kann Quellmarker wie [doc1] in generiertem Text zurückgeben.
StreamingResponse wandelt diese Marker in nummerierte Referenzen um, fügt die entsprechenden Zitationsmetadaten an und fügt der Endnachricht Daumen hoch- und Daumen-runter-Steuerungen hinzu.
Füge Zitate und Feedback zu einer Streaming-Antwort hinzu
Fügen Sie jede Zitation in derselben Reihenfolge hinzu wie ihr Marker im generierten Text. Wenn Text in die Warteschlange eingereiht wird, konvertiert die Streamingantwort [doc1] oder [docs1] mithilfe von CitationUtils.FormatCitationsResponse in [1]. In der Regel musst du das Formatierungsprogramm nicht direkt aufrufen.
using Microsoft.Agents.Core.Models;
var citations = new List<Citation>
{
new(
content: "Contoso offers 30 days of annual leave.",
title: "Contoso employee handbook",
url: "https://www.example.com/handbook")
};
turnContext.StreamingResponse.FeedbackLoopEnabled = true;
turnContext.StreamingResponse.EnableGeneratedByAILabel = true;
turnContext.StreamingResponse.QueueTextChunk(
"Contoso employees receive 30 days of annual leave [doc1].");
turnContext.StreamingResponse.AddCitations(citations);
await turnContext.StreamingResponse.EndStreamAsync(cancellationToken);
AddCitation(citation, position) Verwenden Sie dies, wenn Sie eine bestimmte Referenznummer zuweisen müssen. Verwenden Sie AddCitations(citations), um eine Sammlung in der Reihenfolge der Liste zu nummerieren.
context.streamingResponse.setFeedbackLoop(true)
context.streamingResponse.queueTextChunk(
'Contoso employees receive 30 days of annual leave [doc1].'
)
context.streamingResponse.setCitations([
{
content: 'Contoso offers 30 days of annual leave.',
title: 'Contoso employee handbook',
url: 'https://www.example.com/handbook',
filepath: null
}
])
await context.streamingResponse.endStream()
from microsoft_agents.hosting.core import Citation
context.streaming_response.set_feedback_loop(True)
context.streaming_response.queue_text_chunk(
"Contoso employees receive 30 days of annual leave [doc1]."
)
context.streaming_response.set_citations(
[
Citation(
content="Contoso offers 30 days of annual leave.",
title="Contoso employee handbook",
url="https://www.example.com/handbook",
)
]
)
await context.streaming_response.end_stream()
Eingereichte Rückmeldungen bearbeiten
Registrieren Sie einen AgentApplication.OnFeedbackLoop Handler im Agentenkonstruktor:
public MyAgent(AgentApplicationOptions options) : base(options)
{
OnFeedbackLoop(OnFeedbackAsync);
}
private Task OnFeedbackAsync(
ITurnContext turnContext,
ITurnState turnState,
FeedbackData feedbackData,
CancellationToken cancellationToken)
{
var reaction = feedbackData.ActionValue?.Reaction;
var feedbackText = feedbackData.ActionValue?.Feedback;
var activityId = feedbackData.ReplyToId;
// Store or process the feedback for the referenced activity.
return Task.CompletedTask;
}
import { onTeamsFeedbackLoop } from '@microsoft/agents-hosting-extensions-msteams'
onTeamsFeedbackLoop(app, async (context, state, feedbackData) => {
const reaction = feedbackData.actionValue?.reaction
const feedbackText = feedbackData.actionValue?.feedback
const activityId = feedbackData.replyToId
// Store or process the feedback for the referenced activity.
})
Das Python SDK kann Rückkopplungssteuerungen für eine Streaming-Antwort ermöglichen. Eine typisierte eingehende Feedback-Route wird derzeit nicht bereitgestellt.
Der Wert in FeedbackData.ActionValue.Reaction steht für die Auswahl des Daumen-hoch- oder Daumen-runter-Feedbacks. Es ist getrennt von einer Emoji-Nachrichtenreaktionsaktivität.
Reaktionen auf Nachrichten verwalten
Nachrichtenreaktionen sind Emoji-Reaktionen, die Nutzer einer Nachricht hinzufügen oder daraus entfernen. Sie erscheinen als Nachrichtenreaktionsaktivitäten und nicht als Feedbackschleifen-Übermittlungen.
Registrieren Sie die Standard-Nachrichtenreaktionsrouten AgentApplication :
public MyAgent(AgentApplicationOptions options) : base(options)
{
OnMessageReactionsAdded(OnReactionsAddedAsync);
OnMessageReactionsRemoved(OnReactionsRemovedAsync);
}
private Task OnReactionsAddedAsync(
ITurnContext turnContext,
ITurnState turnState,
CancellationToken cancellationToken)
{
foreach (var reaction in turnContext.Activity.ReactionsAdded)
{
// Process reaction.Type for turnContext.Activity.ReplyToId.
}
return Task.CompletedTask;
}
private Task OnReactionsRemovedAsync(
ITurnContext turnContext,
ITurnState turnState,
CancellationToken cancellationToken)
{
foreach (var reaction in turnContext.Activity.ReactionsRemoved)
{
// Process reaction.Type for turnContext.Activity.ReplyToId.
}
return Task.CompletedTask;
}
import {
onTeamsMessageReactionsAdded,
onTeamsMessageReactionsRemoved
} from '@microsoft/agents-hosting-extensions-msteams'
onTeamsMessageReactionsAdded(app, async (context) => {
for (const reaction of context.activity.reactionsAdded ?? []) {
// Process reaction.type for context.activity.replyToId.
}
})
onTeamsMessageReactionsRemoved(app, async (context) => {
for (const reaction of context.activity.reactionsRemoved ?? []) {
// Process reaction.type for context.activity.replyToId.
}
})
Eine typisierte Route für Teams-Nachrichtenreaktionen wird im Python-SDK derzeit nicht verfügbar gemacht.
Für unterstützte Reaktionstypen und Klientenverhalten siehe: