last ...
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using xAiModels.Models;
|
||||
using xModels.Extensions;
|
||||
using xCommons.Extensions;
|
||||
using xAiModels.Constants;
|
||||
using xAiModels.Models.Dtos;
|
||||
using xExceptions.Constants;
|
||||
using Microsoft.Extensions.AI;
|
||||
using xAiModels.Models.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -177,6 +179,22 @@ namespace xAiModels.Extensions
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate a Request for Retrieve Response in Controllers ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XAiResponseRequest source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Prompt.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a Collection Contains Default Project for Specified Owner or not ...
|
||||
/// </summary>
|
||||
@@ -211,7 +229,7 @@ namespace xAiModels.Extensions
|
||||
var result = !item.IsNullOrDefault();
|
||||
|
||||
//
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -253,7 +271,7 @@ namespace xAiModels.Extensions
|
||||
var result = !item.IsNullOrDefault();
|
||||
|
||||
//
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -293,7 +311,7 @@ namespace xAiModels.Extensions
|
||||
//
|
||||
return item.Id;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get Default Conversation Id from a Collection Contains ...
|
||||
/// </summary>
|
||||
@@ -333,7 +351,38 @@ namespace xAiModels.Extensions
|
||||
var result = item.Id;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ChatMessage ToChatMessages(
|
||||
this XAiMessageDto source
|
||||
)
|
||||
{
|
||||
//
|
||||
// TODO: Handle Files Attached here ...
|
||||
|
||||
//
|
||||
ChatMessage result = null;
|
||||
|
||||
//
|
||||
if (!source.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
result = new ChatMessage
|
||||
{
|
||||
AuthorName =
|
||||
source.Role == XAiChatRole.User &&
|
||||
!source.Owner.IsNullOrDefault()
|
||||
? source.Owner.GetFullname()
|
||||
: string.Empty,
|
||||
Role = source.Role.ToChatRole(),
|
||||
MessageId = source.Id.ToString(),
|
||||
Contents = [new TextContent(source.Content)]
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user