openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/customize-openairesponsescontext-attribute

Branches

Tags

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

Clone

HTTPS

Download ZIP

OpenAI/src/Custom/Chat/Messages/SystemChatMessage.cs

56lines · modecode

1using Microsoft.TypeSpec.Generator.Customizations;
2using System.Collections.Generic;
3
4namespace OpenAI.Chat;
5
6/// <summary>
7/// Represents a chat message of the <c>system</c> role as supplied to a chat completion request. A system message is
8/// generally supplied as the first message to a chat completion request and guides the model's behavior across future
9/// <c>assistant</c> role response messages. These messages may help control behavior, style, tone, and
10/// restrictions for a model-based assistant. Developer messages replace system messages for o1 models and newer.
11/// </summary>
12[CodeGenType("ChatCompletionRequestSystemMessage")]
13[CodeGenVisibility(nameof(SystemChatMessage), CodeGenVisibility.Internal)]
14[CodeGenSuppress("SystemChatMessage", typeof(ChatMessageContent))]
15public partial class SystemChatMessage : ChatMessage
16{
17 /// <summary>
18 /// Creates a new instance of <see cref="SystemChatMessage"/> using a collection of content items.
19 /// For <c>system</c> messages, these can only be of type <c>text</c>.
20 /// </summary>
21 /// <param name="contentParts">
22 /// The collection of content items associated with the message.
23 /// </param>
24 public SystemChatMessage(IEnumerable<ChatMessageContentPart> contentParts)
25 : this(content: new(contentParts), role: ChatMessageRole.System, participantName: null, patch: default)
26 { }
27
28 /// <summary>
29 /// Creates a new instance of <see cref="SystemChatMessage"/> using a collection of content items.
30 /// For <c>system</c> messages, these can only be of type <c>text</c>.
31 /// </summary>
32 /// <param name="contentParts">
33 /// The collection of content items associated with the message.
34 /// </param>
35 public SystemChatMessage(params ChatMessageContentPart[] contentParts)
36 : this(content: new(contentParts), role: ChatMessageRole.System, participantName: null, patch: default)
37 {
38 Argument.AssertNotNullOrEmpty(contentParts, nameof(contentParts));
39 }
40
41 /// <summary>
42 /// Creates a new instance of <see cref="SystemChatMessage"/> with a single item of text content.
43 /// </summary>
44 /// <param name="content"> The text content of the message. </param>
45 public SystemChatMessage(string content)
46 : this(content: new([content]), role: ChatMessageRole.System, participantName: null, patch: default)
47 {
48 Argument.AssertNotNull(content, nameof(content));
49 }
50
51 /// <summary>
52 /// An optional <c>name</c> for the participant.
53 /// </summary>
54 [CodeGenMember("Name")]
55 public string ParticipantName { get; set; }
56}