Table of Contents

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.Object
ChatMessage
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

role System.String

The role of the author of this message. One of system, user, or assistant.

contents IList<MessageContent>

The list of the content messages.

name System.String

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.

toolCalls System.Nullable<IList<ToolCall>>

The tool calls generated by the model.

toolCallId System.String

The 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

role System.String

The role of the author of this message. One of system, user, or assistant.

content System.String

The contents of the message.

name System.String

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.

toolCalls System.Nullable<IList<ToolCall>>

The tool calls generated by the model.

toolCallId System.String

The 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

FunctionCall

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

content System.String
name System.String
toolCalls System.Nullable<IList<ToolCall>>

Returns

ChatMessage

FromSystem(String, String)

public static ChatMessage FromSystem(string content, string name = null)

Parameters

content System.String
name System.String

Returns

ChatMessage

FromTool(String, String)

public static ChatMessage FromTool(string content, string toolCallId)

Parameters

content System.String
toolCallId System.String

Returns

ChatMessage

FromUser(IList<MessageContent>)

public static ChatMessage FromUser(IList<MessageContent> contents)

Parameters

contents IList<MessageContent>

Returns

ChatMessage

FromUser(String, String)

public static ChatMessage FromUser(string content, string name = null)

Parameters

content System.String
name System.String

Returns

ChatMessage