This commit is contained in:
2026-08-01 10:52:50 +03:30
parent 5824eda6cb
commit 2696a9850c
6 changed files with 135 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
using xAiModels.Models;
namespace xAiModels.Configurations
{
public class XAiApiConfiguration
{
/// <summary>
/// Model Providers ...
/// </summary>
public XAiModelDescriptor[] Models { get; set; } = [];
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace xAiModels.Constants
{
public partial struct ConfigurationNodeNames
{
public const string AI_API_NODE = "AiApiConfiguration";
}
}
+13
View File
@@ -0,0 +1,13 @@
namespace xAiModels.Constants
{
/// <summary>
/// Specifiy Provider Type ...
/// </summary>
public enum XAiModelProviderType
{
None,
Ollama,
DeepSeek,
HuggingFace
}
}
+26
View File
@@ -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;
}
}
}
+35
View File
@@ -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;
}
}