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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using xModels.Base;
|
using xModels.Base;
|
||||||
|
using xModels.Dtos;
|
||||||
|
|
||||||
namespace xAiModels.Models
|
namespace xAiModels.Models
|
||||||
{
|
{
|
||||||
@@ -34,6 +35,13 @@ namespace xAiModels.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<XAiMessageDto> Messages { get; set; }
|
public IEnumerable<XAiMessageDto> Messages { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User Identifier ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string OwnerId { get; set; }
|
||||||
|
public XPersonDto Owner { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Project ID ...
|
/// Project ID ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using xAiModels.Constants;
|
using xAiModels.Constants;
|
||||||
using xModels.Base;
|
using xModels.Base;
|
||||||
|
using xModels.Dtos;
|
||||||
|
|
||||||
namespace xAiModels.Models
|
namespace xAiModels.Models
|
||||||
{
|
{
|
||||||
@@ -37,6 +35,13 @@ namespace xAiModels.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime UpdatedAt { get; set; }
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User Identifier ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string OwnerId { get; set; }
|
||||||
|
public XPersonDto Owner { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Conversation Id ...
|
/// Conversation Id ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -46,6 +51,5 @@ namespace xAiModels.Models
|
|||||||
/// Conversation ...
|
/// Conversation ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public XAiConversationDto Conversation { get; set; }
|
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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using xModels.Base;
|
using xModels.Base;
|
||||||
|
using xModels.Dtos;
|
||||||
|
|
||||||
namespace xAiModels.Models
|
namespace xAiModels.Models
|
||||||
{
|
{
|
||||||
@@ -39,6 +40,13 @@ namespace xAiModels.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime UpdatedAt { get; set; }
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User Identifier ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string OwnerId { get; set; }
|
||||||
|
public XPersonDto Owner { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Conversations ...
|
/// Conversations ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<!-- Local Modules -->
|
<!-- Local Modules -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="xDashboard.xModels" Version="1.0.0" />
|
<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" /> -->
|
<!-- <PackageReference Include="xDashboard.xCommons" Version="1.0.0" /> -->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user