microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.0.0-preview.6

Branches

Tags

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

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.AI.Models.OpenAI/Extensions/SystemMessage.cs

25lines · modeblame

73e7847aAlex Acebo1 years ago1using Microsoft.Teams.AI.Messages;
2
3using OpenAI.Chat;
4
5namespace Microsoft.Teams.AI.Models.OpenAI;
6
7public static partial class MessageExtensions
8{
9public static DeveloperMessage ToTeams(this SystemChatMessage message)
10{
11var content = message.Content.Select(c =>
12{
13if (c.Kind == ChatMessageContentPartKind.Text) return c.Text;
14if (c.Kind == ChatMessageContentPartKind.Image) return c.ImageUri.ToString();
15return c.Refusal;
16});
17
18return new DeveloperMessage(string.Join("\n", content));
19}
20
21public static SystemChatMessage ToOpenAI(this DeveloperMessage message)
22{
23return ChatMessage.CreateSystemMessage(message.Content);
24}
25}