diff --git a/Constants/XAiModelProviderType.cs b/Constants/XAiModelProviderType.cs index b7cb76e..5980f17 100644 --- a/Constants/XAiModelProviderType.cs +++ b/Constants/XAiModelProviderType.cs @@ -6,6 +6,7 @@ namespace xAiModels.Constants public enum XAiModelProviderType { None, + OpenAI, Ollama, DeepSeek, HuggingFace diff --git a/Extensions/XAiModelsExtensions.cs b/Extensions/XAiModelsExtensions.cs index 0d4226a..70d87f3 100644 --- a/Extensions/XAiModelsExtensions.cs +++ b/Extensions/XAiModelsExtensions.cs @@ -1,3 +1,5 @@ +using System.Linq; +using xAiModels.Models; using xCommons.Extensions; using xAiModels.Models.Dtos; using xAiModels.Models.Entities; @@ -104,5 +106,71 @@ namespace xAiModels.Extensions // return result; } + + /// + /// Validate a Model Descriptor ... + /// + /// + /// + public static bool IsValid(this XAiModelDescriptor source) + { + // + var result = + !source.IsNullOrDefault() && + !source.Name.IsNullOrEmpty() && + !source.Url.IsNullOrEmpty() && + source.Url.IsValidUrl() && + !source.LLM.IsNullOrEmpty() && + source.Provider != Constants.XAiModelProviderType.None; + + // + return result; + } + + /// + /// Validate Specified Param ... + /// + /// + /// + public static bool IsValid(this XAiPromptParam source) + { + // + var result = + !source.IsNullOrDefault() && + !source.Name.IsNullOrEmpty() && + !source.Param.IsNullOrEmpty(); + + // + return result; + } + + /// + /// Validate Specified Prompt ... + /// + /// + /// + public static bool IsValid(this XAiPromptDescriptor source) + { + // + var result = + !source.IsNullOrDefault() && + !source.Name.IsNullOrEmpty() && + !source.Template.IsNullOrEmpty(); + if (!result) + { + return result; + } + + // + if (source.Params.HasChild()) + { + result = + result && + source.Params.All(x => x.IsValid()); + } + + // + return result; + } } } \ No newline at end of file diff --git a/Models/XAiPromptDescriptor.cs b/Models/XAiPromptDescriptor.cs new file mode 100644 index 0000000..ee091b2 --- /dev/null +++ b/Models/XAiPromptDescriptor.cs @@ -0,0 +1,49 @@ +namespace xAiModels.Models +{ + /// + /// Describe Specified Prompt ... + /// + public class XAiPromptDescriptor + { + /// + /// Prompt Name ... + /// + public string Name { get; set; } + + /// + /// Prompt Template ... + /// + public string Template { get; set; } + + /// + /// Prompt Description ... + /// + public string Description { get; set; } + + /// + /// Prompt Template Params ... + /// + public XAiPromptParam[] Params { get; set; } = []; + } + + /// + /// Specified a Prompt Param ... + /// + public class XAiPromptParam + { + /// + /// Param Name ... + /// + public string Name { get; set; } + + /// + /// Param Identifier ... + /// + public string Param { get; set; } + + /// + /// Parma Description ... + /// + public string Description { get; set; } + } +} \ No newline at end of file diff --git a/xAiModels.csproj b/xAiModels.csproj index 694cfd2..0b61ce5 100644 --- a/xAiModels.csproj +++ b/xAiModels.csproj @@ -20,8 +20,7 @@ - + @@ -36,7 +35,9 @@ + +