Table of Contents

Struct ChatRole

Namespace
OllamaSharp.Models.Chat
Assembly
OllamaSharp.dll

Represents a role within a chat completions interaction, describing the intended purpose of a message.

[JsonConverter(typeof(ChatRoleConverter))]
public readonly struct ChatRole : IEquatable<ChatRole>
Implements
Inherited Members

Constructors

ChatRole(object)

Initializes a new instance of ChatRole using a JSON constructor.

[JsonConstructor]
public ChatRole(object _)

Parameters

_ object

The placeholder parameter for JSON constructor.

ChatRole(string?)

Initializes a new instance of ChatRole with the specified role.

public ChatRole(string? role)

Parameters

role string

The role to initialize with.

Exceptions

ArgumentNullException

Thrown when role is null.

Properties

Assistant

Gets the role that provides responses to system-instructed, user-prompted input.

public static ChatRole Assistant { get; }

Property Value

ChatRole

System

Gets the role that instructs or sets the behavior of the assistant.

public static ChatRole System { get; }

Property Value

ChatRole

Tool

Gets the role that is used to input the result from an external tool.

public static ChatRole Tool { get; }

Property Value

ChatRole

User

Gets the role that provides input for chat completions.

public static ChatRole User { get; }

Property Value

ChatRole

Methods

Equals(ChatRole)

public bool Equals(ChatRole other)

Parameters

other ChatRole

Returns

bool

ToString()

public override string ToString()

Returns

string

Operators

operator ==(ChatRole, ChatRole)

Determines if two ChatRole instances are equal.

public static bool operator ==(ChatRole left, ChatRole right)

Parameters

left ChatRole

The first ChatRole to compare.

right ChatRole

The second ChatRole to compare.

Returns

bool

true if both instances are equal; otherwise, false.

implicit operator ChatRole(string)

Implicitly converts a string to a ChatRole.

public static implicit operator ChatRole(string value)

Parameters

value string

The string value to convert.

Returns

ChatRole

operator !=(ChatRole, ChatRole)

Determines if two ChatRole instances are not equal.

public static bool operator !=(ChatRole left, ChatRole right)

Parameters

left ChatRole

The first ChatRole to compare.

right ChatRole

The second ChatRole to compare.

Returns

bool

true if both instances are not equal; otherwise, false.