diff --git a/Configurations/XAiApiConfiguration.cs b/Configurations/XAiApiConfiguration.cs
index 4856014..323c1bf 100644
--- a/Configurations/XAiApiConfiguration.cs
+++ b/Configurations/XAiApiConfiguration.cs
@@ -1,4 +1,4 @@
-using xAiApi.Models;
+using xAiModels.Models;
namespace xAiApi.Configurations
{
diff --git a/Constants/XAiApiConstants.cs b/Constants/XAiApiConstants.cs
index 4bd17fe..dd30996 100644
--- a/Constants/XAiApiConstants.cs
+++ b/Constants/XAiApiConstants.cs
@@ -14,5 +14,8 @@ namespace xAiApi.Constants
//
public const string XAiEmbeddingModelName = "Embed";
public const string XAiEmbeddingPromptName = "Embedding";
+
+ //
+ public const string XOpenAINoKey = "no-key-required";
}
}
\ No newline at end of file
diff --git a/Constants/XAiProvider.cs b/Constants/XAiProvider.cs
deleted file mode 100644
index 686caee..0000000
--- a/Constants/XAiProvider.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace xAiApi.Constants
-{
- public enum XAiProvider
- {
- None,
- Ollama,
- DeepSeek,
- HuggingFace
- }
-}
\ No newline at end of file
diff --git a/DI/XDIHelperExtension.cs b/DI/XDIHelperExtension.cs
index 9ec3901..70b1002 100644
--- a/DI/XDIHelperExtension.cs
+++ b/DI/XDIHelperExtension.cs
@@ -1,11 +1,11 @@
using System;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using xAiApi.Configurations;
using xAiApi.Constants;
using xAiApi.Extensions;
using xCommons.Extensions;
+using xAiApi.Configurations;
using xExceptions.Constants;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
namespace xAiApi.DI
{
diff --git a/Extensions/XModelsExtensions.cs b/Extensions/XModelsExtensions.cs
index 22e92b2..0e8e712 100644
--- a/Extensions/XModelsExtensions.cs
+++ b/Extensions/XModelsExtensions.cs
@@ -1,34 +1,15 @@
-using System.Collections.Generic;
using System.Linq;
-using xAiApi.Configurations;
using xAiApi.Constants;
-using xAiApi.Models;
+using xAiModels.Models;
using xCommons.Extensions;
+using xAiModels.Extensions;
+using xAiApi.Configurations;
+using System.Collections.Generic;
namespace xAiApi.Extensions
{
public static class XModelsExtensions
{
- ///
- /// 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.XAiProvider.None;
-
- //
- return result;
- }
-
///
/// Validate Configurations ...
///
@@ -51,52 +32,6 @@ namespace xAiApi.Extensions
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;
- }
-
///
/// Extract Default Model Descriptor ...
///
diff --git a/Models/.gitkeep b/Models/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Models/XAiModelDescriptor.cs b/Models/XAiModelDescriptor.cs
deleted file mode 100644
index 2a1ea4e..0000000
--- a/Models/XAiModelDescriptor.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using xAiApi.Constants;
-
-namespace xAiApi.Models
-{
- ///
- /// Describe an Ai Model ...
- ///
- public class XAiModelDescriptor
- {
- ///
- /// Provider Name ...
- ///
- public string Name { get; set; }
-
- ///
- /// LLM Provider Url ...
- ///
- public string Url { get; set; }
-
- ///
- /// Model Name ...
- ///
- public string LLM { get; set; }
-
- ///
- /// Api Key for Connection ...
- ///
- public string ApiKey { get; set; } = null;
-
- ///
- /// Model Provider ...
- ///
- public XAiProvider Provider { get; set; } = XAiProvider.Ollama;
- }
-}
\ No newline at end of file
diff --git a/Models/XAiPromptDescriptor.cs b/Models/XAiPromptDescriptor.cs
deleted file mode 100644
index 0636289..0000000
--- a/Models/XAiPromptDescriptor.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-namespace xAiApi.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/Providers/XAIServiceBase.cs b/Providers/XAIServiceBase.cs
index d109b27..3397865 100644
--- a/Providers/XAIServiceBase.cs
+++ b/Providers/XAIServiceBase.cs
@@ -1,19 +1,24 @@
using System;
+using OpenAI;
+using OllamaSharp;
+using System.Net.Http;
using System.Threading;
+using xAiApi.Constants;
using xAiApi.Interfaces;
+using xAiApi.Extensions;
+using System.ClientModel;
using xCommons.Extensions;
+using xAiModels.Constants;
using xAiModels.Interfaces;
-using xExceptions.Constants;
-using System.Threading.Tasks;
-using System.Collections.Generic;
-using Microsoft.Extensions.Logging;
-using System.Runtime.CompilerServices;
-using Microsoft.Extensions.AI;
using xAiModels.Extensions;
using xAiApi.Configurations;
-using xAiApi.Extensions;
-using System.Net.Http;
-using OllamaSharp;
+using xExceptions.Constants;
+using System.Threading.Tasks;
+using Microsoft.Extensions.AI;
+using System.Collections.Generic;
+using Microsoft.Extensions.Logging;
+using System.ClientModel.Primitives;
+using System.Runtime.CompilerServices;
namespace xAiApi.Providers
{
@@ -161,7 +166,7 @@ namespace xAiApi.Providers
switch (modelDescriptor.Provider)
{
//
- case Constants.XAiProvider.Ollama:
+ case XAiModelProviderType.Ollama:
//
// Instance Ollama Client using Custom HttpCLient ...
var ollamaClient = new OllamaApiClient(httpClient, model);
@@ -169,13 +174,31 @@ namespace xAiApi.Providers
new ChatClientBuilder(ollamaClient)
.Build();
break;
-
+
//
- case Constants.XAiProvider.DeepSeek:
+ case XAiModelProviderType.OpenAI:
+ //
+ // Instance Ollama Client using Custom HttpCLient ...
+ var llamaClient = new OpenAIClient(
+ new ApiKeyCredential(apiKey.IsNullOrEmpty() ? XAiApiConstants.XOpenAINoKey : apiKey),
+ new OpenAIClientOptions
+ {
+ Endpoint = url,
+ Transport = new HttpClientPipelineTransport(httpClient)
+ }
+ );
+ result =
+ llamaClient
+ .GetChatClient(model)
+ .AsIChatClient();
break;
//
- case Constants.XAiProvider.HuggingFace:
+ case XAiModelProviderType.DeepSeek:
+ break;
+
+ //
+ case XAiModelProviderType.HuggingFace:
break;
//
diff --git a/Providers/XAiEmbeddingServiceBase.cs b/Providers/XAiEmbeddingServiceBase.cs
index 34d087e..7056e8b 100644
--- a/Providers/XAiEmbeddingServiceBase.cs
+++ b/Providers/XAiEmbeddingServiceBase.cs
@@ -1,20 +1,21 @@
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.Extensions.Logging;
using OllamaSharp;
-using OllamaSharp.Models;
-using xAiApi.Configurations;
+using System.Threading;
using xAiApi.Constants;
+using xAiModels.Models;
using xAiApi.Extensions;
using xAiApi.Interfaces;
-using xAiApi.Models;
-using xAiModels.Interfaces;
+using OllamaSharp.Models;
using xAiService.Helpers;
using xCommons.Extensions;
+using xAiModels.Extensions;
+using xAiModels.Interfaces;
+using xAiApi.Configurations;
using xExceptions.Constants;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using Microsoft.Extensions.Logging;
namespace xAiApi.Providers
{
diff --git a/appsettings.Development.json b/appsettings.Development.json
index dd8c63f..29f045f 100644
--- a/appsettings.Development.json
+++ b/appsettings.Development.json
@@ -41,15 +41,15 @@
"ApiKey": "",
"Name": "Gemma",
"LLM": "gemma3:1b",
- "Provider": "Ollama",
- "Url": "http://localhost:11434"
+ "Provider": "OpenAI",
+ "Url": "http://178.131.88.93:1112"
},
{
"ApiKey": "",
"Name": "Embed",
"LLM": "bge-m3",
- "Provider": "Ollama",
- "Url": "http://localhost:11434"
+ "Provider": "OpenAI",
+ "Url": "http://178.131.88.93:1113"
}
],
"Prompts": [