// <auto-generated/>

#nullable disable

using System;

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

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