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}">
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/BeWo/View/Master/AiConversationView.xaml.cs b/BeWo/View/Master/AiConversationView.xaml.cs
index 7cc235c17..9f4e75bda 100644
--- a/BeWo/View/Master/AiConversationView.xaml.cs
+++ b/BeWo/View/Master/AiConversationView.xaml.cs
@@ -26,13 +26,10 @@ namespace BeWo.View.Master
///
public partial class AiConversationView : BeWoView
{
- private bool models_loaded = false;
-
public AiConversationView()
{
InitializeComponent();
- RequestNewConversationCommand = new DelegateCommand(RequestNewConversation);
OpenAiSettingCommand = new DelegateCommand(OpenAiSetting);
}
@@ -42,16 +39,11 @@ namespace BeWo.View.Master
set => DataContext = value;
}
- public DelegateCommand RequestNewConversationCommand { get; set; }
public DelegateCommand OpenAiSettingCommand { get; set; }
private void BeWoView_Loaded(object sender, RoutedEventArgs e)
{
- if (models_loaded) return;
- models_loaded = true;
-
- ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => { ViewModel.Models.MakeEqualTo(x); }, true, this);
}
private void ReloadButton_OnClick(object sender, RoutedEventArgs e)
@@ -59,12 +51,6 @@ namespace BeWo.View.Master
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => { ViewModel.Models.MakeEqualTo(x); }, true, this);
}
-
- public void RequestNewConversation()
- {
-
- }
-
public void OpenAiSetting()
{
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) =>
diff --git a/BeWo/ViewModel/AiConversationMessageVM.cs b/BeWo/ViewModel/AiConversationMessageVM.cs
index 90e269819..3a33c102c 100644
--- a/BeWo/ViewModel/AiConversationMessageVM.cs
+++ b/BeWo/ViewModel/AiConversationMessageVM.cs
@@ -2,36 +2,47 @@
using BS.Shared;
using BS.Shared.DataContracts;
+using Newtonsoft.Json;
namespace BeWo.ViewModel
{
+ [JsonObject(MemberSerialization.OptIn)]
public class AiConversationMessageVM : AbstractDCMapperVM
{
- private long? _Oid;
+ private string _ApiMethods;
private string _Context;
+ private string _Context2;
private string _Prompt;
private string _Model;
private string _Result;
+ private DateTime _TimeStamp;
public AiConversationMessageVM(AiConversationMessageDC dc) : base(dc, dc.Oid is null)
{
}
- public long? Oid
+ public string Json
{
- get { return _Oid; }
+ get => JsonConvert.SerializeObject(this, Formatting.Indented);
+ }
+
+ [JsonProperty(Order = 4)]
+ public string ApiMethods
+ {
+ get { return _ApiMethods; }
set
{
- if (!AreDifferent(_Oid, value))
+ if (!AreDifferent(ApiMethods, value))
return;
- _Oid = value;
- StoreDirtyInformation(AreDifferent(DataContract.Oid, value), nameof(Oid));
- FirePropertyChanged(nameof(Oid));
+ _ApiMethods = value;
+ StoreDirtyInformation(AreDifferent(DataContract.ApiMethods, value), nameof(ApiMethods));
+ FirePropertyChanged(nameof(ApiMethods));
}
}
+ [JsonProperty(Order = 3)]
public string Context
{
get { return _Context; }
@@ -46,6 +57,22 @@ namespace BeWo.ViewModel
}
}
+ [JsonProperty(Order = 5)]
+ public string Context2
+ {
+ get { return _Context2; }
+ set
+ {
+ if (!AreDifferent(_Context2, value))
+ return;
+
+ _Context2 = value;
+ StoreDirtyInformation(AreDifferent(DataContract.Context2, value), nameof(Context2));
+ FirePropertyChanged(nameof(Context2));
+ }
+ }
+
+ [JsonProperty(Order = 2)]
public string Prompt
{
get { return _Prompt; }
@@ -60,6 +87,7 @@ namespace BeWo.ViewModel
}
}
+ [JsonProperty(Order = 1)]
public string Model
{
get { return _Model; }
@@ -74,6 +102,7 @@ namespace BeWo.ViewModel
}
}
+ [JsonProperty(Order = 6)]
public string Result
{
get { return _Result; }
@@ -88,22 +117,39 @@ namespace BeWo.ViewModel
}
}
+ [JsonProperty(Order = 7)]
+ public DateTime TimeStamp
+ {
+ get { return _TimeStamp; }
+ set
+ {
+ if (!AreDifferent(_TimeStamp, value))
+ return;
+
+ _TimeStamp = value;
+ StoreDirtyInformation(AreDifferent(DataContract.TimeStamp, value), nameof(TimeStamp));
+ FirePropertyChanged(nameof(TimeStamp));
+ }
+ }
+
protected override void InitByDataContract(AiConversationMessageDC pDataContract)
{
- _Oid = pDataContract.Oid;
_Context = pDataContract.Context;
_Prompt = pDataContract.Prompt;
_Model = pDataContract.Model;
_Result = pDataContract.Result;
+ _TimeStamp = pDataContract.TimeStamp;
+ _Context2 = pDataContract.Context2;
+ _ApiMethods = pDataContract.ApiMethods;
}
protected override AiConversationMessageDC MapToDataContract(AiConversationMessageDC pDataContract, bool doCommit)
{
- pDataContract.Oid = _Oid;
pDataContract.Context = _Context;
pDataContract.Prompt = _Prompt;
pDataContract.Model = _Model;
pDataContract.Result = _Result;
+ pDataContract.TimeStamp = _TimeStamp;
return pDataContract;
}
diff --git a/BeWo/ViewModel/AiConversationVM.cs b/BeWo/ViewModel/AiConversationVM.cs
index 4e4868dae..f29201453 100644
--- a/BeWo/ViewModel/AiConversationVM.cs
+++ b/BeWo/ViewModel/AiConversationVM.cs
@@ -17,7 +17,7 @@ namespace BeWo.ViewModel
private string _Modell;
private string _View;
private AiSettingDC _Setting;
- private ObservableCollection _Messages;
+ private AiConversationMessageListVM _Messages;
public AiConversationVM() : this(new AiConversationDC()) { }
public AiConversationVM(AiConversationDC dc) : base(dc, dc.Oid is null)
@@ -104,9 +104,9 @@ namespace BeWo.ViewModel
}
}
- public ObservableCollection Messages
+ public AiConversationMessageListVM Messages
{
- get { return _Messages; }
+ get { return _Messages ?? (_Messages = new AiConversationMessageListVM()); }
set
{
if (!AreDifferent(_Messages, value))
@@ -127,9 +127,7 @@ namespace BeWo.ViewModel
_Setting = pDataContract.Setting;
if (pDataContract.Messages is object)
- _Messages = new ObservableCollection(pDataContract.Messages);
- else
- _Messages = new ObservableCollection();
+ _Messages = new AiConversationMessageListVM(pDataContract.Messages);
}
protected override AiConversationDC MapToDataContract(AiConversationDC pDataContract, bool doCommit)
@@ -139,7 +137,7 @@ namespace BeWo.ViewModel
pDataContract.Modell = _Modell;
pDataContract.View = _View;
pDataContract.Setting = _Setting;
- pDataContract.Messages = _Messages.ToList();
+ pDataContract.Messages = _Messages?.CopyToDCList(doCommit);
return pDataContract;
}
diff --git a/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs b/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
index e83b6cc84..7e79a4806 100644
--- a/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
+++ b/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
@@ -16,21 +17,41 @@ namespace BeWo.ViewModel.ListViewModel
{
public class AiConversationListVM : AbstractDCListMapperVM
{
+ private string _MessageInput;
+ private string _ContextInput;
+
private AiModelDC _SelectedModel;
public AiConversationListVM() : this(null)
{
- VMList.Add(new AiConversationVM()
- {
- Created = DateTime.Now,
- Displayname = "Chat1"
- });
+ //VMList.Add(new AiConversationVM()
+ //{
+ // Created = DateTime.Now,
+ // Displayname = "Chat1",
+ // Messages = new AiConversationMessageListVM(new List()
+ // {
+ // new AiConversationMessageDC() {
+ // Context = "context",
+ // Model = "model",
+ // Oid = 1,
+ // Prompt = "prompt",
+ // Result = "result" }
+ // })
+ //});
}
public AiConversationListVM(List pDCs) : base(pDCs)
{
Models = new ObservableSortCollection();
+
+ SendNewMessageCommand = new DelegateCommand(SendNewMessage, CanSendNewMessage);
+ RequestNewConversationCommand = new DelegateCommand(RequestNewConversation);
+ TestCommand = new DelegateCommand(Test);
}
+ public DelegateCommand SendNewMessageCommand { get; set; }
+ public DelegateCommand RequestNewConversationCommand { get; set; }
+ public DelegateCommand TestCommand { get; set; }
+
public ObservableCollection Models { get; set; }
public AiModelDC SelectedModel {
get { return _SelectedModel; }
@@ -43,5 +64,97 @@ namespace BeWo.ViewModel.ListViewModel
FirePropertyChanged(nameof(SelectedModel));
}
}
+ public string MessageInput
+ {
+ get { return _MessageInput; }
+ set
+ {
+ if (MessageInput == value)
+ return;
+
+ _MessageInput = value;
+ FirePropertyChanged(nameof(MessageInput));
+ }
+ }
+
+ public string ContextInput
+ {
+ get { return _ContextInput; }
+ set
+ {
+ if (ContextInput == value)
+ return;
+
+ _ContextInput = value;
+ FirePropertyChanged(nameof(ContextInput));
+ }
+ }
+
+ public void SendNewMessage()
+ {
+ var msg = MessageInput;
+
+ var context = ContextInput;
+
+ ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.SendNewMessage(SelectedVM.CommitToDataContract(), context, msg), (message) =>
+ {
+ SelectedVM.Messages.VMList.Add(new AiConversationMessageVM(message));
+ });
+ }
+
+ public void RequestNewConversation()
+ {
+ var dc = new AiConversationDC();
+
+ dc.Created = DateTime.Now;
+ dc.Displayname = "Example";
+ dc.Modell = SelectedModel?.ToString();
+
+ var vm = new AiConversationVM(dc);
+
+ VMList.Add(vm);
+ }
+
+ public void Test()
+ {
+ var limit = 5;
+
+ var models = ServiceFacade.DoOperationsEnhancedServiceSnyc(x => x.GetAiModels());
+ Models.MakeEqualTo(models);
+
+ VMList.Clear();
+
+ foreach (var vm in Models)
+ {
+ var dc = new AiConversationDC();
+
+ dc.Created = DateTime.Now;
+ dc.Displayname = "Example";
+ dc.Modell = vm.ToString();
+
+ var pvm = new AiConversationVM(dc);
+
+ VMList.Add(pvm);
+ }
+
+ var msg = "Wie alt ist Frau Müller?";
+ var context = "Frau Müller wurde am 1.1.1950 geboren. Aktuelle haben wir folgende Universalzeit: " + DateTime.Now.ToUniversalTime();
+
+ for (var i = 0; i < limit; i++)
+ {
+ foreach (var vm in VMList)
+ {
+ ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.SendNewMessage(vm.CommitToDataContract(), context, msg), (message) =>
+ {
+ vm.Messages.VMList.Add(new AiConversationMessageVM(message));
+ });
+ }
+ }
+ }
+
+ private bool CanSendNewMessage()
+ {
+ return SelectedVM is object;
+ }
}
}
diff --git a/BeWo/ViewModel/ListViewModel/AiConversationMessageListVM.cs b/BeWo/ViewModel/ListViewModel/AiConversationMessageListVM.cs
new file mode 100644
index 000000000..8f3d85626
--- /dev/null
+++ b/BeWo/ViewModel/ListViewModel/AiConversationMessageListVM.cs
@@ -0,0 +1,25 @@
+using BeWo.ServiceProxy;
+using BS.Shared.DataContracts;
+using BS.Shared.Extensions;
+using ChatController.Utilities.Extensions;
+using DevExpress.Mvvm;
+using DevExpress.XtraPrinting.Native;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Threading;
+
+namespace BeWo.ViewModel.ListViewModel
+{
+ public class AiConversationMessageListVM : AbstractDCListMapperVM
+ {
+ public AiConversationMessageListVM() : this(null) { }
+ public AiConversationMessageListVM(List pDCs) : base(pDCs)
+ {
+
+ }
+ }
+}
diff --git a/Service/Service.csproj b/Service/Service.csproj
index 8bdcbb9d5..99ed77e34 100644
--- a/Service/Service.csproj
+++ b/Service/Service.csproj
@@ -587,7 +587,6 @@
-
@@ -601,6 +600,12 @@
+
+
+
+
+
+