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
_objectThe placeholder parameter for JSON constructor.
ChatRole(string?)
Initializes a new instance of ChatRole with the specified role.
public ChatRole(string? role)
Parameters
rolestringThe role to initialize with.
Exceptions
- ArgumentNullException
Thrown when
roleis null.
Properties
Assistant
Gets the role that provides responses to system-instructed, user-prompted input.
public static ChatRole Assistant { get; }
Property Value
System
Gets the role that instructs or sets the behavior of the assistant.
public static ChatRole System { get; }
Property Value
Tool
Gets the role that is used to input the result from an external tool.
public static ChatRole Tool { get; }
Property Value
User
Gets the role that provides input for chat completions.
public static ChatRole User { get; }
Property Value
Methods
Equals(ChatRole)
public bool Equals(ChatRole other)
Parameters
otherChatRole
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(ChatRole, ChatRole)
Determines if two ChatRole instances are equal.
public static bool operator ==(ChatRole left, ChatRole right)
Parameters
Returns
- bool
trueif 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
valuestringThe string value to convert.
Returns
operator !=(ChatRole, ChatRole)
Determines if two ChatRole instances are not equal.
public static bool operator !=(ChatRole left, ChatRole right)
Parameters
Returns
- bool
trueif both instances are not equal; otherwise,false.