diff --git a/Server/Components/AICore/Facade/LLM/BaseLLMApiClient.cs b/Server/Components/AICore/Facade/LLM/BaseLLMApiClient.cs index 846e51932..6b81f50c2 100644 --- a/Server/Components/AICore/Facade/LLM/BaseLLMApiClient.cs +++ b/Server/Components/AICore/Facade/LLM/BaseLLMApiClient.cs @@ -10,6 +10,7 @@ using System.Text.Json; using BS.Shared.Interface; using BeWo.ServerUtils.ApiFacade; using BS.Shared.Logger; +using BS.Shared; namespace AICore.Facade.LLM { diff --git a/Server/Components/AICore/Facade/LLM/OllamaApiClient.cs b/Server/Components/AICore/Facade/LLM/OllamaApiClient.cs index 37f9c04d6..090e2390c 100644 --- a/Server/Components/AICore/Facade/LLM/OllamaApiClient.cs +++ b/Server/Components/AICore/Facade/LLM/OllamaApiClient.cs @@ -15,9 +15,14 @@ namespace AICore.Facade.LLM { public class OllamaApiClient : BaseLLMApiClient { - public OllamaApiClient(string base_url, string api_key) : base(base_url, api_key) - { + private AiModelSource _aiModelSource; + public OllamaApiClient(string base_url, string api_key, AiModelSource modelSource = AiModelSource.ollama) : base(base_url, api_key) + { + _aiModelSource = modelSource; + + if (modelSource != AiModelSource.ollama && modelSource != AiModelSource.ollama2) + throw new NotImplementedException("err4548975"); } public override ApiResponse> GetAiModelle() @@ -48,7 +53,7 @@ namespace AICore.Facade.LLM throw new NotImplementedException(); } - var data = response.Data.models.Select(x => new AiModelDC(BS.Shared.AiModelSource.ollama, x.name, x.details.max_context_size)); + var data = response.Data.models.Select(x => new AiModelDC(_aiModelSource, x.name, x.details.max_context_size)); return ApiResponse>.SuccessResponse(data); } diff --git a/Server/Components/AICore/Facade/LLM/OpenWebApiClient.cs b/Server/Components/AICore/Facade/LLM/OpenWebApiClient.cs index 703a2f5bb..81fe5872f 100644 --- a/Server/Components/AICore/Facade/LLM/OpenWebApiClient.cs +++ b/Server/Components/AICore/Facade/LLM/OpenWebApiClient.cs @@ -48,7 +48,7 @@ namespace AICore.Facade.LLM throw new NotImplementedException(); } - var data = response.Data.data.Select(x => new AiModelDC(BS.Shared.AiModelSource.openwebui, x.name, x.details?.max_context_size ?? -2)); + var data = response.Data.data.Select(x => new AiModelDC(AiModelSource.openwebui, x.name, x.details?.max_context_size ?? -2)); return ApiResponse>.SuccessResponse(data); } diff --git a/Service/BeWoServiceEnums.cs b/Service/BeWoServiceEnums.cs index fe5b8e164..6d4a327ae 100644 --- a/Service/BeWoServiceEnums.cs +++ b/Service/BeWoServiceEnums.cs @@ -11,7 +11,7 @@ namespace BeWo.Service { OpenWebUIUrl, OllamaUrl, - OllamaUrl2, + Ollama2Url, XRechnungApiUrl, StoredFilesFolderPath, StoredTenantFilesFolderPath, diff --git a/Service/ServiceProxy/ServiceFacade.cs b/Service/ServiceProxy/ServiceFacade.cs index 14a4454aa..59a9698eb 100644 --- a/Service/ServiceProxy/ServiceFacade.cs +++ b/Service/ServiceProxy/ServiceFacade.cs @@ -12,12 +12,23 @@ namespace BeWo.Service.ServiceProxy public static class ServiceFacade { private static readonly Lazy _OpenWebApiClient = new Lazy(() - => new OpenWebApiClient(MergedConfig.GetSetting(WebConfigSetting.OpenWebUIUrl), MergedConfig.GetSecretSetting(WebSecretConfigSetting.OpenWebUIKey))); + => new OpenWebApiClient( + MergedConfig.GetSetting(WebConfigSetting.OpenWebUIUrl), + MergedConfig.GetSecretSetting(WebSecretConfigSetting.OpenWebUIKey))); + private static readonly Lazy _OllamaApiClient = new Lazy(() - => new OllamaApiClient(MergedConfig.GetSetting(WebConfigSetting.OllamaUrl), MergedConfig.GetSecretSetting(WebSecretConfigSetting.OllamaKey))); + => new OllamaApiClient( + MergedConfig.GetSetting(WebConfigSetting.OllamaUrl), + MergedConfig.GetSecretSetting(WebSecretConfigSetting.OllamaKey))); + private static readonly Lazy _Ollama2ApiClient = new Lazy(() - => new OllamaApiClient(MergedConfig.GetSetting(WebConfigSetting.OllamaUrl2), MergedConfig.GetSecretSetting(WebSecretConfigSetting.OllamaKey))); - private static readonly Lazy _XRechnungFacade = new Lazy(() => new XRechnungApiClient()); + => new OllamaApiClient( + MergedConfig.GetSetting(WebConfigSetting.Ollama2Url), + MergedConfig.GetSecretSetting(WebSecretConfigSetting.OllamaKey), + AiModelSource.ollama2)); + + private static readonly Lazy _XRechnungFacade = new Lazy(() + => new XRechnungApiClient()); public static OpenWebApiClient OpenWebApiClient => _OpenWebApiClient.Value; public static OllamaApiClient OllamaApiClient => _OllamaApiClient.Value;