// <auto-generated/>

#nullable disable

using System;

namespace OpenAI.Chat
{
    internal static partial class ChatMessageRoleExtensions
    {
        public static string ToSerialString(this Chat.ChatMessageRole value) => value switch
        {
            Chat.ChatMessageRole.System => "system",
            Chat.ChatMessageRole.Developer => "developer",
            Chat.ChatMessageRole.User => "user",
            Chat.ChatMessageRole.Assistant => "assistant",
            Chat.ChatMessageRole.Tool => "tool",
            Chat.ChatMessageRole.Function => "function",
            _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageRole value.")
        };

        public static Chat.ChatMessageRole ToChatMessageRole(this string value)
        {
            if (StringComparer.OrdinalIgnoreCase.Equals(value, "system"))
            {
                return Chat.ChatMessageRole.System;
            }
            if (StringComparer.OrdinalIgnoreCase.Equals(value, "developer"))
            {
                return Chat.ChatMessageRole.Developer;
            }
            if (StringComparer.OrdinalIgnoreCase.Equals(value, "user"))
            {
                return Chat.ChatMessageRole.User;
            }
            if (StringComparer.OrdinalIgnoreCase.Equals(value, "assistant"))
            {
                return Chat.ChatMessageRole.Assistant;
            }
            if (StringComparer.OrdinalIgnoreCase.Equals(value, "tool"))
            {
                return Chat.ChatMessageRole.Tool;
            }
            if (StringComparer.OrdinalIgnoreCase.Equals(value, "function"))
            {
                return Chat.ChatMessageRole.Function;
            }
            throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageRole value.");
        }
    }
}
