diff --git a/Extensions/ChatRoleExtensions.cs b/Extensions/ChatRoleExtensions.cs new file mode 100644 index 0000000..b83bb8f --- /dev/null +++ b/Extensions/ChatRoleExtensions.cs @@ -0,0 +1,162 @@ +using Microsoft.Extensions.AI; +using xAiModels.Constants; +using xCommons.Extensions; + +namespace xAiModels.Extensions +{ + /// + /// Extensions for ChatRole ... + /// + public static class ChatRoleExtensions + { + /// + /// Normalize an String to Propper Chat Role Value ... + /// > + /// + /// + /// + public static string GetChatRoleTitle(this string source) + { + // + var result = XAiChatRoles.None; + + // + if (source.ToNormalString() == XAiChatRoles.None.ToNormalString()) + { + result = XAiChatRoles.None; + } + else if (source.ToNormalString() == XAiChatRoles.User.ToNormalString()) + { + result = XAiChatRoles.User; + } + else if (source.ToNormalString() == XAiChatRoles.Tool.ToNormalString()) + { + result = XAiChatRoles.Tool; + } + else if (source.ToNormalString() == XAiChatRoles.System.ToNormalString()) + { + result = XAiChatRoles.System; + } + else if (source.ToNormalString() == XAiChatRoles.Assistant.ToNormalString()) + { + result = XAiChatRoles.Assistant; + } + + // + return result; + } + + /// + /// Get Chat Role Title from Chat Role Class ... + /// + /// + /// + /// + public static string GetRole(this ChatRole source) + { + // + var result = source.Value + .GetChatRoleTitle(); + + // + return result; + } + + /// + /// Generate Chat Role Class Based on role Title ... + /// + /// + /// + public static ChatRole ToChatRole(this string source) + { + // + var role = source.GetChatRoleTitle(); + ChatRole result = new ChatRole(role); + + // + return result; + } + + /// + /// Extract Chat Role Enum from Chat Role ... + /// + /// + /// + /// + /// + public static XAiChatRole ToChatRole(this ChatRole source) + { + // + var role = source + .GetRole() + .GetChatRoleTitle(); + + // + XAiChatRole result = XAiChatRole.User; + + // + if (role == XAiChatRoles.User) + { + result = XAiChatRole.User; + } + else if (role == XAiChatRoles.Tool) + { + result = XAiChatRole.Tool; + } + else if (role == XAiChatRoles.System) + { + result = XAiChatRole.System; + } + else if (role == XAiChatRoles.Assistant) + { + result = XAiChatRole.Assistant; + } + + // + return result; + } + + /// + /// Validate an String as Chat Role ... + /// + /// + /// + public static bool IsValid(this string source) + { + // + var result = + source != XAiChatRoles.None && + source.ToNormalString() != XAiChatRoles.None.ToNormalString(); + + // + return result; + } + + /// + /// Validate Role ... + /// > + /// + /// + /// + public static bool IsValid(this XAiChatRole source) + { + // + var result = source != XAiChatRole.None; + return result; + } + + /// + /// Validate Role ... + /// > + /// + /// + /// + public static bool IsValid(this ChatRole source) + { + // + var role = source.ToChatRole(); + var result = role.IsValid(); + return result; + } + } +} \ No newline at end of file diff --git a/Models/XAiConversationDto.cs b/Models/XAiConversationDto.cs index 48286b6..9b0bd62 100644 --- a/Models/XAiConversationDto.cs +++ b/Models/XAiConversationDto.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using xModels.Base; +using xModels.Dtos; namespace xAiModels.Models { @@ -34,6 +35,13 @@ namespace xAiModels.Models /// public IEnumerable Messages { get; set; } + /// + /// User Identifier ... + /// + /// + public string OwnerId { get; set; } + public XPersonDto Owner { get; set; } + /// /// Project ID ... /// diff --git a/Models/XAiMessageDto.cs b/Models/XAiMessageDto.cs index 2101a25..d4eb29a 100644 --- a/Models/XAiMessageDto.cs +++ b/Models/XAiMessageDto.cs @@ -1,9 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using xAiModels.Constants; using xModels.Base; +using xModels.Dtos; namespace xAiModels.Models { @@ -37,6 +35,13 @@ namespace xAiModels.Models /// public DateTime UpdatedAt { get; set; } + /// + /// User Identifier ... + /// + /// + public string OwnerId { get; set; } + public XPersonDto Owner { get; set; } + /// /// Conversation Id ... /// @@ -46,6 +51,5 @@ namespace xAiModels.Models /// Conversation ... /// public XAiConversationDto Conversation { get; set; } - } } \ No newline at end of file diff --git a/Models/XAiMessageUpdateDto.cs b/Models/XAiMessageUpdateDto.cs new file mode 100644 index 0000000..cbed543 --- /dev/null +++ b/Models/XAiMessageUpdateDto.cs @@ -0,0 +1,45 @@ +using System; +using xAiModels.Constants; +using xModels.Base; + +namespace xAiModels.Models +{ + public class XAiMessageUpdateDto : XBaseDto + { + /// + /// Message Sequence ... + /// + public long Cequense { get; set; } + + /// + /// Id of Message ... + /// + public Guid Id { get; set; } + + /// + /// Message of Chat ... + /// + public string Content { get; set; } + + /// + /// Role of Message ... + /// + public XAiChatRole Role { get; set; } + + /// + /// Updated Time ... + /// + public DateTime UpdatedAt { get; set; } + + /// + /// User Identifier ... + /// + /// + public string OwnerId { get; set; } + + /// + /// Conversation Id ... + /// + public Guid ConversationId { get; set; } + } +} \ No newline at end of file diff --git a/Models/XAiProjectDto.cs b/Models/XAiProjectDto.cs index a134ead..56cf706 100644 --- a/Models/XAiProjectDto.cs +++ b/Models/XAiProjectDto.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using xModels.Base; +using xModels.Dtos; namespace xAiModels.Models { @@ -39,6 +40,13 @@ namespace xAiModels.Models /// public DateTime UpdatedAt { get; set; } + /// + /// User Identifier ... + /// + /// + public string OwnerId { get; set; } + public XPersonDto Owner { get; set; } + /// /// Conversations ... /// diff --git a/xAiModels.csproj b/xAiModels.csproj index a9040c7..74221ca 100644 --- a/xAiModels.csproj +++ b/xAiModels.csproj @@ -23,6 +23,7 @@ +