UNPKG

@microsoft/agents-activity

Version:

Microsoft 365 Agents SDK for JavaScript. Activity Protocol serialization and deserialization.

65 lines 2.39 kB
"use strict"; /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.addAIToActivity = void 0; /** * Adds an AI entity to an activity to indicate that the content was generated by AI. * * @param activity - The activity to which the AI entity will be added. The activity's entities array will be initialized if it doesn't exist. * @param citations - Optional array of client citations to include with the AI-generated content. * Citations provide references to sources used in generating the content and are displayed in Teams. * @param usageInfo - Optional sensitivity usage information that provides context about the content's sensitivity level. * This helps users understand any special handling requirements for the content. * * @remarks * This function enhances the activity with metadata that helps clients (like Microsoft Teams) * understand that the content is AI-generated and optionally includes citations and sensitivity information. * * @example * ```typescript * import { Activity } from '../activity'; * import { addAIToActivity, ClientCitation } from './AIEntity'; * * const activity: Activity = { * type: 'message', * text: 'Based on the documents, here are the key findings...' * }; * * const citations: ClientCitation[] = [{ * '@type': 'Claim', * position: 1, * appearance: { * '@type': 'DigitalDocument', * name: 'Research Report 2024', * abstract: 'Key findings from the annual research report', * url: 'https://example.com/report.pdf', * image: { * '@type': 'ImageObject', * name: 'PDF' * } * } * }]; * * // Add AI entity with citations * addAIToActivity(activity, citations); * ``` */ const addAIToActivity = (activity, citations, usageInfo) => { var _a; const aiEntity = { type: 'https://schema.org/Message', '@type': 'Message', '@context': 'https://schema.org', '@id': '', additionalType: ['AIGeneratedContent'], citation: citations, usageInfo }; (_a = activity.entities) !== null && _a !== void 0 ? _a : (activity.entities = []); activity.entities.push(aiEntity); }; exports.addAIToActivity = addAIToActivity; //# sourceMappingURL=AIEntity.js.map