last ...
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
using Microsoft.Extensions.AI;
|
||||
using xAiModels.Constants;
|
||||
using xCommons.Extensions;
|
||||
|
||||
namespace xAiModels.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions for ChatRole ...
|
||||
/// </summary>
|
||||
public static class ChatRoleExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Normalize an String to Propper Chat Role Value ...
|
||||
/// <see cref="XAiChatRoles"/>>
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Chat Role Title from Chat Role Class ...
|
||||
/// <see cref="XAiChatRoles"/>
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetRole(this ChatRole source)
|
||||
{
|
||||
//
|
||||
var result = source.Value
|
||||
.GetChatRoleTitle();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate Chat Role Class Based on role Title ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static ChatRole ToChatRole(this string source)
|
||||
{
|
||||
//
|
||||
var role = source.GetChatRoleTitle();
|
||||
ChatRole result = new ChatRole(role);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract Chat Role Enum from Chat Role ...
|
||||
/// <see cref="ChatRole"/>
|
||||
/// <see cref="XAiChatRole"/>
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate an String as Chat Role ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this string source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
source != XAiChatRoles.None &&
|
||||
source.ToNormalString() != XAiChatRoles.None.ToNormalString();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Role ...
|
||||
/// <see cref="XAiChatRole"/>>
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XAiChatRole source)
|
||||
{
|
||||
//
|
||||
var result = source != XAiChatRole.None;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Role ...
|
||||
/// <see cref="ChatRole"/>>
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this ChatRole source)
|
||||
{
|
||||
//
|
||||
var role = source.ToChatRole();
|
||||
var result = role.IsValid();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public IEnumerable<XAiMessageDto> Messages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User Identifier ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string OwnerId { get; set; }
|
||||
public XPersonDto Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Project ID ...
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User Identifier ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string OwnerId { get; set; }
|
||||
public XPersonDto Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Conversation Id ...
|
||||
/// </summary>
|
||||
@@ -46,6 +51,5 @@ namespace xAiModels.Models
|
||||
/// Conversation ...
|
||||
/// </summary>
|
||||
public XAiConversationDto Conversation { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using xAiModels.Constants;
|
||||
using xModels.Base;
|
||||
|
||||
namespace xAiModels.Models
|
||||
{
|
||||
public class XAiMessageUpdateDto : XBaseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Message Sequence ...
|
||||
/// </summary>
|
||||
public long Cequense { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id of Message ...
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Message of Chat ...
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Role of Message ...
|
||||
/// </summary>
|
||||
public XAiChatRole Role { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Updated Time ...
|
||||
/// </summary>
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User Identifier ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string OwnerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Conversation Id ...
|
||||
/// </summary>
|
||||
public Guid ConversationId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User Identifier ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string OwnerId { get; set; }
|
||||
public XPersonDto Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Conversations ...
|
||||
/// </summary>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<!-- Local Modules -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="xDashboard.xModels" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.AI" Version="10.4.1" />
|
||||
<!-- <PackageReference Include="xDashboard.xCommons" Version="1.0.0" /> -->
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user