microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
affd7569cfa8bd4a83b86066b8636721ea186364

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.AI/ChatPlugin.cs

70lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.AI.Messages;
5using Microsoft.Teams.AI.Prompts;
6
7namespace Microsoft.Teams.AI;
8
9/// <summary>
10/// a component that can change the
11/// way a ChatPrompt works
12/// </summary>
13public interface IChatPlugin
14{
15 /// <summary>
16 /// called before a prompt sends
17 /// a message
18 /// </summary>
19 /// <param name="prompt">the prompt</param>
20 /// <param name="message">the message</param>
21 /// <param name="options">the model options</param>
22 /// <returns>the transformed message</returns>
23 public Task<IMessage> OnBeforeSend<TOptions>(IChatPrompt<TOptions> prompt, IMessage message, TOptions? options = default, CancellationToken cancellationToken = default);
24
25 /// <summary>
26 /// called after a prompt sends
27 /// a message
28 /// </summary>
29 /// <param name="prompt">the prompt</param>
30 /// <param name="message">the message</param>
31 /// <param name="options">the model options</param>
32 /// <returns>the transformed message</returns>
33 public Task<IMessage> OnAfterSend<TOptions>(IChatPrompt<TOptions> prompt, IMessage message, TOptions? options = default, CancellationToken cancellationToken = default);
34
35 /// <summary>
36 /// called before a prompt function is called
37 /// </summary>
38 /// <param name="prompt">the prompt</param>
39 /// <param name="function">the function</param>
40 /// <param name="call">the function call</param>
41 /// <returns>the transformed call</returns>
42 public Task<FunctionCall> OnBeforeFunctionCall<TOptions>(IChatPrompt<TOptions> prompt, IFunction function, FunctionCall call, CancellationToken cancellationToken = default);
43
44 /// <summary>
45 /// called after a prompt function is called
46 /// </summary>
47 /// <param name="prompt">the prompt</param>
48 /// <param name="function">the function</param>
49 /// <param name="call">the function call</param>
50 /// <param name="output">the functions return value</param>
51 /// <returns>the transformed response</returns>
52 public Task<object?> OnAfterFunctionCall<TOptions>(IChatPrompt<TOptions> prompt, IFunction function, FunctionCall call, object? output, CancellationToken cancellationToken = default);
53
54 /// <summary>
55 /// Modify the prompt functions passed to the model.
56 /// </summary>
57 /// <param name="prompt">the prompt</param>
58 /// <param name="functions">a copy of the configured chat prompt functions</param>
59 /// <param name="cancellationToken">the cancellation token</param>
60 /// <returns>the transformed functions</returns>
61 public Task<FunctionCollection> OnBuildFunctions<TOptions>(IChatPrompt<TOptions> prompt, FunctionCollection functions, CancellationToken cancellationToken = default);
62
63 /// <summary>
64 /// Modify the prompt instructions passed to the model.
65 /// </summary>
66 /// <param name="prompt">the prompt</param>
67 /// <param name="instructions">the instructions</param>
68 /// <returns>the transformed instructions</returns>
69 public Task<DeveloperMessage?> OnBuildInstructions<TOptions>(IChatPrompt<TOptions> prompt, DeveloperMessage? instructions);
70}