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/DeveloperChatMessage.cs

57lines · modecode

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