Class ChatMessage
- Namespace
- OpenAI.ObjectModels.RequestModels
- Assembly
- AntRunnerLib.dll
The contents of the message. Messages must be an array of message objects, where each object has a role (either “system”, “user”, or “assistant”) and content (the content of the message) and an optional name
public class ChatMessage
- Inheritance
-
System.ObjectChatMessage
- Inherited Members
-
System.Object.Equals(System.Object)System.Object.Equals(System.Object, System.Object)System.Object.GetHashCode()System.Object.GetType()System.Object.MemberwiseClone()System.Object.ReferenceEquals(System.Object, System.Object)System.Object.ToString()
Constructors
ChatMessage()
public ChatMessage()
ChatMessage(String, IList<MessageContent>, String, Nullable<IList<ToolCall>>, String)
public ChatMessage(string role, IList<MessageContent> contents, string name = null, IList<ToolCall>? toolCalls = null, string toolCallId = null)
Parameters
roleSystem.StringThe role of the author of this message. One of system, user, or assistant.
contentsIList<MessageContent>The list of the content messages.
nameSystem.StringThe name of the author of this message. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
toolCallsSystem.Nullable<IList<ToolCall>>The tool calls generated by the model.
toolCallIdSystem.StringThe tool function call id generated by the model
ChatMessage(String, String, String, Nullable<IList<ToolCall>>, String)
public ChatMessage(string role, string content, string name = null, IList<ToolCall>? toolCalls = null, string toolCallId = null)
Parameters
roleSystem.StringThe role of the author of this message. One of system, user, or assistant.
contentSystem.StringThe contents of the message.
nameSystem.StringThe name of the author of this message. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
toolCallsSystem.Nullable<IList<ToolCall>>The tool calls generated by the model.
toolCallIdSystem.StringThe tool function call id generated by the model
Properties
Content
[JsonIgnore]
public string Content { get; set; }
Property Value
- System.String
ContentCalculated
The contents of the message.
[JsonPropertyName("content")]
public object ContentCalculated { get; set; }
Property Value
- System.Object
Contents
[JsonIgnore]
public IList<MessageContent>? Contents { get; set; }
Property Value
- System.Nullable<IList<MessageContent>>
FunctionCall
Deprecated and replaced by tool_calls. The name and arguments of a function that should be called, as generated by the model.
[JsonPropertyName("function_call")]
public FunctionCall FunctionCall { get; set; }
Property Value
Name
The name of the author of this message. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
[JsonPropertyName("name")]
public string Name { get; set; }
Property Value
- System.String
Role
The role of the author of this message. One of system, user, or assistant.
[JsonPropertyName("role")]
public string Role { get; set; }
Property Value
- System.String
ToolCallId
Required for tool role messages. Tool call that this message is responding to.
[JsonPropertyName("tool_call_id")]
public string ToolCallId { get; set; }
Property Value
- System.String
ToolCalls
The tool calls generated by the model, such as function calls.
[JsonPropertyName("tool_calls")]
public IList<ToolCall>? ToolCalls { get; set; }
Property Value
- System.Nullable<IList<ToolCall>>
Methods
FromAssistant(String, String, Nullable<IList<ToolCall>>)
public static ChatMessage FromAssistant(string content, string name = null, IList<ToolCall>? toolCalls = null)
Parameters
contentSystem.StringnameSystem.StringtoolCallsSystem.Nullable<IList<ToolCall>>
Returns
FromSystem(String, String)
public static ChatMessage FromSystem(string content, string name = null)
Parameters
contentSystem.StringnameSystem.String
Returns
FromTool(String, String)
public static ChatMessage FromTool(string content, string toolCallId)
Parameters
contentSystem.StringtoolCallIdSystem.String
Returns
FromUser(IList<MessageContent>)
public static ChatMessage FromUser(IList<MessageContent> contents)
Parameters
contentsIList<MessageContent>
Returns
FromUser(String, String)
public static ChatMessage FromUser(string content, string name = null)
Parameters
contentSystem.StringnameSystem.String