last ...
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using xAiModels.Models;
|
||||
|
||||
namespace xAiModels.Configurations
|
||||
{
|
||||
public class XAiApiConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// Model Providers ...
|
||||
/// </summary>
|
||||
public XAiModelDescriptor[] Models { get; set; } = [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace xAiModels.Constants
|
||||
{
|
||||
public partial struct ConfigurationNodeNames
|
||||
{
|
||||
public const string AI_API_NODE = "AiApiConfiguration";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace xAiModels.Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifiy Provider Type ...
|
||||
/// </summary>
|
||||
public enum XAiModelProviderType
|
||||
{
|
||||
None,
|
||||
Ollama,
|
||||
DeepSeek,
|
||||
HuggingFace
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using xAiModels.Constants;
|
||||
|
||||
namespace xAiModels.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Describe a Provided Model ...
|
||||
/// </summary>
|
||||
public class XAiModelDescriptor
|
||||
{
|
||||
/// <summary>
|
||||
/// Provider Name ...
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// LLM Provider Url ...
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Model Name ...
|
||||
/// </summary>
|
||||
public string LLM { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Api Key for Connection ...
|
||||
/// </summary>
|
||||
public string ApiKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specified Model Provider Type ...
|
||||
/// </summary>
|
||||
public XAiModelProviderType Provider { get; set; } = XAiModelProviderType.Ollama;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user