microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.AI/Prompts/ChatPrompt/ChatPrompt.Chain.cs
32lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Json.Schema; |
| 5 | |
| 6 | namespace Microsoft.Teams.AI.Prompts; |
| 7 | |
| 8 | public partial class ChatPrompt<TOptions> |
| 9 | { |
| 10 | /// <summary> |
| 11 | /// provide another chat prompt to be used |
| 12 | /// as a function |
| 13 | /// </summary> |
| 14 | /// <param name="prompt">the chat prompt</param> |
| 15 | public ChatPrompt<TOptions> Chain(IChatPrompt<TOptions> prompt) |
| 16 | { |
| 17 | Functions.Add(new Function( |
| 18 | prompt.Name, |
| 19 | prompt.Description, |
| 20 | new JsonSchemaBuilder().Properties( |
| 21 | ("text", new JsonSchemaBuilder().Type(SchemaValueType.String).Description("text to send")) |
| 22 | ), |
| 23 | async (string text) => |
| 24 | { |
| 25 | var res = await prompt.Send(text); |
| 26 | return res.Content; |
| 27 | } |
| 28 | )); |
| 29 | |
| 30 | return this; |
| 31 | } |
| 32 | } |