From fa442a32613c2d5a73a6c9902ae69711cee92a15 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Fri, 28 Mar 2025 10:05:29 +0100 Subject: [PATCH] temp --- BeWo/BeWo.csproj | 1 + .../GeneratedOperationsEnhancedService.cs | 25 ++ BeWo/ServiceProxy/ServiceFacade.cs | 257 +++++++++--------- BeWo/View/Master/AiConversationView.xaml | 73 ++++- BeWo/View/Master/AiConversationView.xaml.cs | 14 - BeWo/ViewModel/AiConversationMessageVM.cs | 64 ++++- BeWo/ViewModel/AiConversationVM.cs | 12 +- .../ListViewModel/AiConversationListVM.cs | 123 ++++++++- .../AiConversationMessageListVM.cs | 25 ++ Service/Service.csproj | 7 +- .../IOperationsEnhancedService.cs | 5 +- .../OperationsEnhancedServiceImp.cs | 73 ++++- Service/ServiceProxy/MikePHPScriptFacade.cs | 71 +++++ Service/ai/system_prompt.txt | 19 ++ Service/ai/system_prompt2.txt | 12 + Shared/Core/WebClientFacade.cs | 90 +++--- .../DataContracts/AiConversationMessageDC.cs | 14 +- .../MikePHPContracts/AiMessageRequest.cs | 25 ++ .../MikePHPContracts/AiMessageRequest2.cs | 22 ++ .../MikePHPContracts/AiMessageResponse.cs | 18 ++ .../MikePHPContracts/AiMessageResponse2.cs | 29 ++ Shared/Extensions/ObjectExtensions.cs | 65 ++++- Shared/Shared.csproj | 5 + 23 files changed, 827 insertions(+), 222 deletions(-) create mode 100644 BeWo/ViewModel/ListViewModel/AiConversationMessageListVM.cs create mode 100644 Service/ai/system_prompt.txt create mode 100644 Service/ai/system_prompt2.txt create mode 100644 Shared/DataContracts/MikePHPContracts/AiMessageRequest.cs create mode 100644 Shared/DataContracts/MikePHPContracts/AiMessageRequest2.cs create mode 100644 Shared/DataContracts/MikePHPContracts/AiMessageResponse.cs create mode 100644 Shared/DataContracts/MikePHPContracts/AiMessageResponse2.cs diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index e7b683cf4..c58ffca13 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -1208,6 +1208,7 @@ + diff --git a/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs b/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs index edf7be5a1..8fe3d963b 100644 --- a/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs +++ b/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs @@ -21,6 +21,10 @@ namespace BeWo.ServiceProxy [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiModelDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationMessageDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiSettingDC))] object Method1(object input, object input2); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/Method2", ReplyAction="http://tempuri.org/IOperationsEnhancedService/Method2Response")] @@ -29,6 +33,10 @@ namespace BeWo.ServiceProxy [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiModelDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationMessageDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiSettingDC))] object Method2(object input, object input2); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/Method3", ReplyAction="http://tempuri.org/IOperationsEnhancedService/Method3Response")] @@ -37,6 +45,10 @@ namespace BeWo.ServiceProxy [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiModelDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationMessageDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiSettingDC))] object Method3(object input, object input2); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/Method4", ReplyAction="http://tempuri.org/IOperationsEnhancedService/Method4Response")] @@ -45,11 +57,19 @@ namespace BeWo.ServiceProxy [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiModelDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.List))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiConversationMessageDC))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BS.Shared.DataContracts.AiSettingDC))] object Method4(object input, object input2); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/GetAiModels", ReplyAction="http://tempuri.org/IOperationsEnhancedService/GetAiModelsResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/GetAiModelsBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] System.Collections.Generic.List GetAiModels(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/SendNewMessage", ReplyAction="http://tempuri.org/IOperationsEnhancedService/SendNewMessageResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/SendNewMessageBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.Shared.DataContracts.AiConversationMessageDC SendNewMessage(BS.Shared.DataContracts.AiConversationDC conversation, string context, string input); } [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] @@ -110,5 +130,10 @@ namespace BeWo.ServiceProxy { return base.Channel.GetAiModels(); } + + public BS.Shared.DataContracts.AiConversationMessageDC SendNewMessage(BS.Shared.DataContracts.AiConversationDC conversation, string context, string input) + { + return base.Channel.SendNewMessage(conversation, context, input); + } } } diff --git a/BeWo/ServiceProxy/ServiceFacade.cs b/BeWo/ServiceProxy/ServiceFacade.cs index 5ef6f7a0e..c702a8118 100644 --- a/BeWo/ServiceProxy/ServiceFacade.cs +++ b/BeWo/ServiceProxy/ServiceFacade.cs @@ -49,23 +49,23 @@ namespace BeWo.ServiceProxy _ServerName += "/"; _EndpointAddresses = new Dictionary - { - { typeof(IQueryService), new EndpointAddress(_ServerName + "QueryService.svc") }, - { typeof(IStreamingService), new EndpointAddress(_ServerName + "StreamingService.svc") }, - { typeof(IEmployeeService), new EndpointAddress(_ServerName + "EmployeeService.svc") }, - { typeof(ICustomerService), new EndpointAddress(_ServerName + "CustomerService.svc") }, - { typeof(IUserService), new EndpointAddress(_ServerName + "UserService.svc") }, - { typeof(IValueListService), new EndpointAddress(_ServerName + "ValueListService.svc") }, - { typeof(IDownloadService), new EndpointAddress(_ServerName + "DownloadService.svc") }, - { typeof(IResourceService), new EndpointAddress(_ServerName + "ResourceService.svc") }, - { typeof(IOperationsService), new EndpointAddress(_ServerName + "OperationsService.svc") }, - { typeof(IOperationsEnhancedService), new EndpointAddress(_ServerName + "OperationsEnhancedService.svc") }, - { typeof(IAnalysisService), new EndpointAddress(_ServerName + "AnalysisService.svc") }, - { typeof(IMailService), new EndpointAddress(_ServerName + "MailService.svc") }, - { typeof(IAccountingService), new EndpointAddress(_ServerName + "AccountingService.svc") }, - { typeof(IGkvAccountingService), new EndpointAddress(_ServerName + "GkvAccountingService.svc") }, + { + { typeof(IQueryService), new EndpointAddress(_ServerName + "QueryService.svc") }, + { typeof(IStreamingService), new EndpointAddress(_ServerName + "StreamingService.svc") }, + { typeof(IEmployeeService), new EndpointAddress(_ServerName + "EmployeeService.svc") }, + { typeof(ICustomerService), new EndpointAddress(_ServerName + "CustomerService.svc") }, + { typeof(IUserService), new EndpointAddress(_ServerName + "UserService.svc") }, + { typeof(IValueListService), new EndpointAddress(_ServerName + "ValueListService.svc") }, + { typeof(IDownloadService), new EndpointAddress(_ServerName + "DownloadService.svc") }, + { typeof(IResourceService), new EndpointAddress(_ServerName + "ResourceService.svc") }, + { typeof(IOperationsService), new EndpointAddress(_ServerName + "OperationsService.svc") }, + { typeof(IOperationsEnhancedService), new EndpointAddress(_ServerName + "OperationsEnhancedService.svc") }, + { typeof(IAnalysisService), new EndpointAddress(_ServerName + "AnalysisService.svc") }, + { typeof(IMailService), new EndpointAddress(_ServerName + "MailService.svc") }, + { typeof(IAccountingService), new EndpointAddress(_ServerName + "AccountingService.svc") }, + { typeof(IGkvAccountingService), new EndpointAddress(_ServerName + "GkvAccountingService.svc") }, { typeof(IReportService), new EndpointAddress(_ServerName + "ReportService.svc") } - }; + }; } @@ -76,11 +76,11 @@ namespace BeWo.ServiceProxy public static void DoOperationsEnhancedServiceSnyc(Action pAction) => DoSync(pAction); - public static void DoOperationsEnhancedServiceSnyc(Func pFunc) + public static T DoOperationsEnhancedServiceSnyc(Func pFunc) => DoSync(pFunc); public static void DoOperationsEnhancedServiceAsnyc(Action pAction, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null) => DoAsync(pAction, pCallback, showWaitDialog, caller?.Dispatcher); - public static void DoOperationsEnhancedServiceAsnyc(Func < IOperationsEnhancedService, T> pFunc, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null) + public static void DoOperationsEnhancedServiceAsnyc(Func pFunc, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null) => DoAsync(pFunc, pCallback, showWaitDialog, caller?.Dispatcher); public static void DoAccountingServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) @@ -115,17 +115,17 @@ namespace BeWo.ServiceProxy public static void DoAnalysisServiceAsync(Func pFunc, Action pCallBack) { DoAsync(pFunc, pCallBack, true); - - } - public static void DoAnalysisServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) - { - DoAsync(pFunc, pCallBack, showWaitDialog); - } - public static void DoAccountingServiceSync(Action pAction) - { - pAction.Invoke(GetInstance()); - } + } + public static void DoAnalysisServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) + { + DoAsync(pFunc, pCallBack, showWaitDialog); + + } + public static void DoAccountingServiceSync(Action pAction) + { + pAction.Invoke(GetInstance()); + } // public static void DoAnalysisServiceAsync(Action pAction) @@ -191,21 +191,21 @@ namespace BeWo.ServiceProxy } } - public static T DoDownloadServiceSync(Func pFunc) - { - try - { - return pFunc.Invoke(GetInstance()); - } - catch (Exception e) - { - ShowErrorMessage(e); - } + public static T DoDownloadServiceSync(Func pFunc) + { + try + { + return pFunc.Invoke(GetInstance()); + } + catch (Exception e) + { + ShowErrorMessage(e); + } - return default(T); - } + return default(T); + } - public static void DoEmployeeServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) + public static void DoEmployeeServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) { DoAsync(pFunc, pCallBack, showWaitDialog); } @@ -232,57 +232,57 @@ namespace BeWo.ServiceProxy } } - public static T DoEmployeeServiceSync(Func pFunc) - { - try - { - return pFunc.Invoke(GetInstance()); - } - catch (Exception e) - { - ShowErrorMessage(e); - } + public static T DoEmployeeServiceSync(Func pFunc) + { + try + { + return pFunc.Invoke(GetInstance()); + } + catch (Exception e) + { + ShowErrorMessage(e); + } - return default(T); - } + return default(T); + } #region Wohnheim public static void DoWohnheimServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) - { - DoAsync(pFunc, pCallBack, showWaitDialog); - } - public static void DoWohnheimServiceAsync(Func pFunc, Action pCallBack) - { - DoAsync(pFunc, pCallBack, true); - } - public static void DoWohnheimServiceAsync(Action pAction) - { - DoAsync(pAction, true); - } - public static void DoWohnheimServiceSync(Action pAction) - { - try - { - pAction.Invoke(GetInstance()); - } - catch (Exception e) - { - ShowErrorMessage(e); - } - } - public static T DoWohnheimServiceSync(Func pFunc) - { - try - { - return pFunc.Invoke(GetInstance()); - } - catch (Exception e) - { - ShowErrorMessage(e); - } + { + DoAsync(pFunc, pCallBack, showWaitDialog); + } + public static void DoWohnheimServiceAsync(Func pFunc, Action pCallBack) + { + DoAsync(pFunc, pCallBack, true); + } + public static void DoWohnheimServiceAsync(Action pAction) + { + DoAsync(pAction, true); + } + public static void DoWohnheimServiceSync(Action pAction) + { + try + { + pAction.Invoke(GetInstance()); + } + catch (Exception e) + { + ShowErrorMessage(e); + } + } + public static T DoWohnheimServiceSync(Func pFunc) + { + try + { + return pFunc.Invoke(GetInstance()); + } + catch (Exception e) + { + ShowErrorMessage(e); + } - return default(T); - } + return default(T); + } #endregion #region GkvAccounting @@ -353,7 +353,7 @@ namespace BeWo.ServiceProxy return default(T); } - + public static void DoMultipleAccountingServicesAsync(List> pActions, Action pAllDoneCallBack) { DoMulitpleAsync(pActions, pAllDoneCallBack, true); @@ -501,11 +501,11 @@ namespace BeWo.ServiceProxy DoAsync(pAction, true); } - public static void DoResourceServiceAsync(Action pAction, Action pCallback) - { - DoAsync(pAction, pCallback, true); - } - + public static void DoResourceServiceAsync(Action pAction, Action pCallback) + { + DoAsync(pAction, pCallback, true); + } + public static void DoStreamingServiceAsync(Func pFunc, Action pCallBack, Action pErrorCallBack) { DoAsync(pFunc, pCallBack, pErrorCallBack, true); @@ -521,20 +521,20 @@ namespace BeWo.ServiceProxy DoAsync(pFunc, pCallBack, showWaitDialog); } - public static T DoUserServiceSync(Func pFunc) - { - return pFunc.Invoke(GetInstance()); - } + public static T DoUserServiceSync(Func pFunc) + { + return pFunc.Invoke(GetInstance()); + } public static void DoUserServiceAsync(Action pAction, bool showWaitDialog) { DoAsync(pAction, showWaitDialog); } - public static void DoUserServiceAsync(Action pAction, Action pCallBack, bool showWaitDialog) - { - DoAsync(pAction, pCallBack, showWaitDialog); - } + public static void DoUserServiceAsync(Action pAction, Action pCallBack, bool showWaitDialog) + { + DoAsync(pAction, pCallBack, showWaitDialog); + } public static void DoValueListServiceAsync(Func pFunc, Action pCallBack) { @@ -570,12 +570,12 @@ namespace BeWo.ServiceProxy DoAsync(pFunc, pCallBack, true); } - public static void DoReportServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) - { - DoAsync(pFunc, pCallBack, showWaitDialog); - } + public static void DoReportServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) + { + DoAsync(pFunc, pCallBack, showWaitDialog); + } - public static void DoReportServiceSync(Action pAction) + public static void DoReportServiceSync(Action pAction) { try { @@ -656,14 +656,14 @@ namespace BeWo.ServiceProxy { DoUserServiceAsync(s => s.GetAllUsersCompact().Cast().ToList(), r => pCallBack(r), true); } - else if (typeof (T) == typeof (ResourceDC)) + else if (typeof(T) == typeof(ResourceDC)) { DoResourceServiceAsync(s => s.GetAllResources().Cast().ToList(), pCallBack, true); } - else if (typeof (T) == typeof (TextModuleDC)) - { - DoOperationsServiceAsync(s => s.GetAllTextModules().Cast().ToList(), pCallBack); - } + else if (typeof(T) == typeof(TextModuleDC)) + { + DoOperationsServiceAsync(s => s.GetAllTextModules().Cast().ToList(), pCallBack); + } else { throw new NotImplementedException(); @@ -683,18 +683,19 @@ namespace BeWo.ServiceProxy where TClient : ClientBase, TInterface, new() where TInterface : class { - Action action = pCallback; - - if (dispatcher != null) + + if(dispatcher is null) { - action = (t) => dispatcher.BeginInvoke( - DispatcherPriority.Normal, - (Action)delegate - { - pCallback(t); - }); + dispatcher = BeWoApp.Current.Dispatcher; } + Action action = (t) => dispatcher.BeginInvoke( + DispatcherPriority.Normal, + (Action)delegate + { + pCallback(t); + }); + DoAsync(pFunc, action, showWaitDialog); } @@ -775,7 +776,7 @@ namespace BeWo.ServiceProxy { Action action = pCallback; - if(dispatcher != null) + if (dispatcher != null) { action = () => dispatcher.BeginInvoke( DispatcherPriority.Normal, @@ -898,7 +899,7 @@ namespace BeWo.ServiceProxy } private static void DoSync(Action pAction) - where TClient : ClientBase, TInterface, new () + where TClient : ClientBase, TInterface, new() where TInterface : class { try @@ -965,17 +966,17 @@ namespace BeWo.ServiceProxy { lClient = new TClient(); - if(!_ProxyCache.ContainsKey(lClient.GetType())) - { - _ProxyCache.Add(typeof(TClient), lClient); - } + if (!_ProxyCache.ContainsKey(lClient.GetType())) + { + _ProxyCache.Add(typeof(TClient), lClient); + } #if DEBUG if (DebugConfig.CurrentConfig is DebugConfig current && current.EnableAutoRemoteDebugging) { if (lClient.Endpoint.Binding is BasicHttpBinding binding) { - if(_ServerName?.StartsWith("https") ?? true) + if (_ServerName?.StartsWith("https") ?? true) { binding.Security.Mode = BasicHttpSecurityMode.Transport; } @@ -992,7 +993,7 @@ namespace BeWo.ServiceProxy lClient.Endpoint.Address = EndpointAddresses[typeof(TInterface)]; - + } diff --git a/BeWo/View/Master/AiConversationView.xaml b/BeWo/View/Master/AiConversationView.xaml index 21555a933..235140cf8 100644 --- a/BeWo/View/Master/AiConversationView.xaml +++ b/BeWo/View/Master/AiConversationView.xaml @@ -18,7 +18,7 @@ HorizontalAlignment="Stretch" VerticalAlignment="Stretch" d:DataContext="{d:DesignInstance Type=listviewmodel:AiConversationListVM}" - d:DesignHeight="300" + d:DesignHeight="600" d:DesignWidth="600" Focusable="True" Loaded="BeWoView_Loaded" @@ -135,21 +135,69 @@ - + + ItemsSource="{Binding VMList}" + SelectedItem="{Binding SelectedVM}"> - - - + + + + + + + + + + + + + + +