last ...
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using Microsoft.Extensions.AI;
|
||||
using xCommons.Extensions;
|
||||
|
||||
namespace xAiModels.Extensions
|
||||
{
|
||||
public static class ChatResponseExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Validate a Chat Response ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this ChatResponse source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
source is not null &&
|
||||
!source.IsNullOrDefault() &&
|
||||
!string.IsNullOrWhiteSpace(source.Text) &&
|
||||
source.FinishReason == ChatFinishReason.Stop;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Linq;
|
||||
using xAiModels.Configurations;
|
||||
using xAiModels.Models;
|
||||
using xCommons.Extensions;
|
||||
|
||||
namespace xAiModels.Extensions
|
||||
{
|
||||
public static class XAiApiConfigurationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Validate Api Configuration ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XAiApiConfiguration source)
|
||||
{
|
||||
return
|
||||
!source.IsNullOrDefault() &&
|
||||
source.Models.HasChild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Default Model Descriptor ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static XAiModelDescriptor GetDefaultModel(this XAiApiConfiguration source)
|
||||
{
|
||||
//
|
||||
XAiModelDescriptor result = null;
|
||||
|
||||
//
|
||||
if (source.IsValid())
|
||||
{
|
||||
result = source.Models.First();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user