using xAiModels.Models;
using xCommons.Extensions;
using xAiService.Services;
using xExceptions.Constants;
using xIdentityModels.Models;
using Microsoft.Extensions.AI;
using System.Collections.Generic;
namespace xAiService.Extensions
{
public static class XAiServiceExtensions
{
///
/// Validate User Info ...
///
///
///
public static bool IsValid(this XUserClaimsInfoDto source)
{
//
var result =
!source.IsNullOrDefault() &&
!source.UserId.IsNullOrEmpty() &&
!source.AccessToken.IsNullOrEmpty();
//
return result;
}
///
/// Validate User Info ...
///
///
///
public static void Validate(
this XUserClaimsInfoDto source,
XException invalidException = XException.InvalidArgs
)
{
//
var isValid = source.IsValid();
if (!isValid)
{
invalidException.Throw();
}
}
///
/// Converts To AITools ...
///
///
///
///
public static IList ToAITools(
this IList source,
XAiMcpClient client
)
{
//
if (client.IsNullOrDefault())
{
XException.InvalidArgs.Throw();
}
//
var result = new List();
//
foreach (var tool in source)
{
result.Add(new XAiMcpAIFunction(client, tool));
}
//
return result;
}
}
}