microsoft/teams.net

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
436972edd2a63f773497d45cdc1de6342c7a1c20

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

28lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.AI.Messages;
5
6using OpenAI.Chat;
7
8namespace Microsoft.Teams.AI.Models.OpenAI;
9
10public static partial class MessageExtensions
11{
12 public static DeveloperMessage ToTeams(this SystemChatMessage message)
13 {
14 var content = message.Content.Select(c =>
15 {
16 if (c.Kind == ChatMessageContentPartKind.Text) return c.Text;
17 if (c.Kind == ChatMessageContentPartKind.Image) return c.ImageUri.ToString();
18 return c.Refusal;
19 });
20
21 return new DeveloperMessage(string.Join("\n", content));
22 }
23
24 public static SystemChatMessage ToOpenAI(this DeveloperMessage message)
25 {
26 return ChatMessage.CreateSystemMessage(message.Content);
27 }
28}