From 388cde699383e35d7efbab012c67832af8752537 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Thu, 3 Jul 2025 14:17:31 +0200 Subject: [PATCH] Send message --- .../AiEnhancedServiceImp.cs | 4 +++ Service/ServiceProxy/OpenWebApiClient.cs | 33 +++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Service/ServiceImplementations/AiEnhancedServiceImp.cs b/Service/ServiceImplementations/AiEnhancedServiceImp.cs index be985f001..2fc481b1f 100644 --- a/Service/ServiceImplementations/AiEnhancedServiceImp.cs +++ b/Service/ServiceImplementations/AiEnhancedServiceImp.cs @@ -33,6 +33,10 @@ namespace BeWo.Service.ServiceImplementations [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)] public class AiEnhancedServiceImp : IAiEnhancedService { + // Was wird alles benötigt: + // - WebConfig + // - DBs + public AiConfigDC GetAiConfig() { var configs = DAOFactory.GenericDAO.GetAllActive(); diff --git a/Service/ServiceProxy/OpenWebApiClient.cs b/Service/ServiceProxy/OpenWebApiClient.cs index 5a6a076ee..e2761dfda 100644 --- a/Service/ServiceProxy/OpenWebApiClient.cs +++ b/Service/ServiceProxy/OpenWebApiClient.cs @@ -101,29 +101,26 @@ namespace BeWo.Service.ServiceProxy _PostClientFacade.JsonObject = payload; var response = _PostClientFacade.GetAnonymousTypeAsync(sub_url, response_format, _ErrorExtractor).GetAwaiter().GetResult(); - //var result = response.GetResponseData(); - + var json = response.GetResponseData(); - //var json = JsonConvert.DeserializeAnonymousType(result, response_format); + foreach (var choice in json.choices) + { + if (choice?.message is object && !string.IsNullOrEmpty(choice.message.content)) + { + var total_ns = json.usage.total_duration; + var total_ms = total_ns / 1000000; + + duration = (int)total_ms; + model = json.model; - //foreach (var choice in json.choices) - //{ - // if (choice?.message is object && !string.IsNullOrEmpty(choice.message.content)) - // { - // var total_ns = json.usage.total_duration; - // var total_ms = total_ns / 1000000; - // duration = (int)total_ms; + var assi_msg = BS.Shared.Core.Utils.ConvertToISO88591(choice.message.content); - // model = json.model; + message = assi_msg; - // var assi_msg = BS.Shared.Core.Utils.ConvertToISO88591(choice.message.content); - - // message = assi_msg; - - // return response; - // } - //} + return ApiResponse.SuccessResponse(assi_msg); + } + } return ApiResponse.FailureResponse("Keine Antwort"); }