microsoft/teams.net

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.0.1

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 · modeblame

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