microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.AI/BaseChatPlugin.cs
43lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.AI.Messages; |
| 5 | using Microsoft.Teams.AI.Prompts; |
| 6 | |
| 7 | namespace Microsoft.Teams.AI; |
| 8 | |
| 9 | /// <summary> |
| 10 | /// A base implementation of <see cref="IChatPlugin"/> with no-op methods. |
| 11 | /// </summary> |
| 12 | public abstract class BaseChatPlugin : IChatPlugin |
| 13 | { |
| 14 | public virtual Task<IMessage> OnBeforeSend<TOptions>(IChatPrompt<TOptions> prompt, IMessage message, TOptions? options = default, CancellationToken cancellationToken = default) |
| 15 | { |
| 16 | return Task.FromResult(message); |
| 17 | } |
| 18 | |
| 19 | public virtual Task<IMessage> OnAfterSend<TOptions>(IChatPrompt<TOptions> prompt, IMessage message, TOptions? options = default, CancellationToken cancellationToken = default) |
| 20 | { |
| 21 | return Task.FromResult(message); |
| 22 | } |
| 23 | |
| 24 | public virtual Task<FunctionCall> OnBeforeFunctionCall<TOptions>(IChatPrompt<TOptions> prompt, IFunction function, FunctionCall call, CancellationToken cancellationToken = default) |
| 25 | { |
| 26 | return Task.FromResult(call); |
| 27 | } |
| 28 | |
| 29 | public virtual Task<object?> OnAfterFunctionCall<TOptions>(IChatPrompt<TOptions> prompt, IFunction function, FunctionCall call, object? output, CancellationToken cancellationToken = default) |
| 30 | { |
| 31 | return Task.FromResult(output); |
| 32 | } |
| 33 | |
| 34 | public virtual Task<FunctionCollection> OnBuildFunctions<TOptions>(IChatPrompt<TOptions> prompt, FunctionCollection functions, CancellationToken cancellationToken = default) |
| 35 | { |
| 36 | return Task.FromResult(functions); |
| 37 | } |
| 38 | |
| 39 | public virtual Task<DeveloperMessage?> OnBuildInstructions<TOptions>(IChatPrompt<TOptions> prompt, DeveloperMessage? instructions) |
| 40 | { |
| 41 | return Task.FromResult(instructions); |
| 42 | } |
| 43 | } |