UIContextType -> AiActionType

This commit is contained in:
2026-05-26 12:30:29 +02:00
parent 709937eee3
commit 9c10386b87
46 changed files with 396 additions and 625 deletions

View File

@@ -31,7 +31,7 @@ namespace BeWo.ServiceProxy
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/GetAiConversations", ReplyAction="http://tempuri.org/IAiEnhancedService/GetAiConversationsResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/GetAiConversationsBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC> GetAiConversations(BS.Shared.AiContextType uicontext, System.Nullable<long> oid);
System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC> GetAiConversations(BS.Shared.AiActionType actionType, System.Nullable<long> oid);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/CreateAiConversation", ReplyAction="http://tempuri.org/IAiEnhancedService/CreateAiConversationResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/CreateAiConversationBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
@@ -61,7 +61,7 @@ namespace BeWo.ServiceProxy
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/CheckContextSize", ReplyAction="http://tempuri.org/IAiEnhancedService/CheckContextSizeResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/CheckContextSizeBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
bool CheckContextSize(BS.Shared.AiContextType aiContextType, System.Collections.Generic.Dictionary<BS.Shared.TableID, System.Collections.Generic.List<long>> context, System.Nullable<long> modell_oid);
bool CheckContextSize(BS.Shared.AiActionType actionType, System.Collections.Generic.Dictionary<BS.Shared.TableID, System.Collections.Generic.List<long>> context, System.Nullable<long> modell_oid);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteinFolder", ReplyAction="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteinFolderResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteinFolderBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")]
@@ -171,9 +171,9 @@ namespace BeWo.ServiceProxy
return base.Channel.GetAiModels();
}
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC> GetAiConversations(BS.Shared.AiContextType uicontext, System.Nullable<long> oid)
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiConversationDC> GetAiConversations(BS.Shared.AiActionType actionType, System.Nullable<long> oid)
{
return base.Channel.GetAiConversations(uicontext, oid);
return base.Channel.GetAiConversations(actionType, oid);
}
public BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversation(BS.Shared.DataContracts.Feature.AI.AiConversationDC conversation, long modell_oid)
@@ -206,9 +206,9 @@ namespace BeWo.ServiceProxy
return base.Channel.SendNewMessage(conversation, message);
}
public bool CheckContextSize(BS.Shared.AiContextType aiContextType, System.Collections.Generic.Dictionary<BS.Shared.TableID, System.Collections.Generic.List<long>> context, System.Nullable<long> modell_oid)
public bool CheckContextSize(BS.Shared.AiActionType actionType, System.Collections.Generic.Dictionary<BS.Shared.TableID, System.Collections.Generic.List<long>> context, System.Nullable<long> modell_oid)
{
return base.Channel.CheckContextSize(aiContextType, context, modell_oid);
return base.Channel.CheckContextSize(actionType, context, modell_oid);
}
public System.Collections.Generic.List<BS.Shared.DataContracts.Feature.AI.AiPromptbausteinFolderDC> GetAiPromptbausteinFolder(BS.Shared.AiActionType aiActionType)

View File

@@ -19,7 +19,7 @@ namespace BeWo.Services
{
public Control GetAiConversationControl(AiConversationChatViewModel vm)
{
var styleString = getStyleString(vm.AiContext);
var styleString = getStyleString(vm.ActionType);
var control = styleString is object ? new AiConversationChatView(vm, styleString) : new AiConversationChatView(vm);
@@ -52,18 +52,21 @@ namespace BeWo.Services
return control;
}
private string getStyleString(AiContextType uIContext) {
switch (uIContext)
private string getStyleString(AiActionType actionType) {
switch (actionType)
{
case AiContextType.SupportConceptNavigation: return "ModuleAiControlSupportConceptStyle";
case AiContextType.CustomerNavigation: return "ModuleAiControlCustomerStyle";
case AiContextType.PersonNavigation: return "ModuleAiControlPersonStyle";
case AiContextType.EmployeeNavigation: return "ModuleAiControlEmployeeStyle";
case AiContextType.OrganisationNavigation: return "ModuleAiControlOrganisationStyle";
case AiContextType.ServiceRecord: return "ModuleAiControlZeiterfassungStyle";
case AiContextType.CustomerDetail: return "ModuleAiControlCustomerStyle";
case AiContextType.PersonDetail: return "ModuleAiControlPersonStyle";
case AiContextType.EmployeeDetail: return "ModuleAiControlEmployeeStyle";
case AiActionType.ServiceRecordConversation: return "ModuleAiControlZeiterfassungStyle";
case AiActionType.ServiceRecordDocumentation: return "ModuleAiControlZeiterfassungStyle";
//case AiContextType.SupportConceptNavigation: return "ModuleAiControlSupportConceptStyle";
//case AiContextType.CustomerNavigation: return "ModuleAiControlCustomerStyle";
//case AiContextType.PersonNavigation: return "ModuleAiControlPersonStyle";
//case AiContextType.EmployeeNavigation: return "ModuleAiControlEmployeeStyle";
//case AiContextType.OrganisationNavigation: return "ModuleAiControlOrganisationStyle";
//case AiContextType.ServiceRecord: return "ModuleAiControlZeiterfassungStyle";
//case AiContextType.CustomerDetail: return "ModuleAiControlCustomerStyle";
//case AiContextType.PersonDetail: return "ModuleAiControlPersonStyle";
//case AiContextType.EmployeeDetail: return "ModuleAiControlEmployeeStyle";
}
return null;

View File

@@ -17,15 +17,10 @@ namespace BeWo.Services
{
public class BeWoWindowFactory
{
private Dictionary<AiContextType, string> _UIContext2Header = new Dictionary<AiContextType, string>()
private Dictionary<AiActionType, string> _UIContext2Header = new Dictionary<AiActionType, string>()
{
{AiContextType.ServiceRecord, "KI Chat: Zeiterfassung" },
{AiContextType.CustomerNavigation, "KI Chat: Klienten Übersicht" },
{AiContextType.PersonNavigation, "KI Chat: Personen Übersicht" },
{AiContextType.EmployeeNavigation, "KI Chat: Mitarbeiter Übersicht" },
{AiContextType.OrganisationNavigation, "KI Chat: Organisation Übersicht" },
{AiContextType.SupportConceptNavigation, "KI Chat: Hilfeplan Übersicht" },
{AiContextType.CustomerDetail, "KI Chat: Klient" },
{AiActionType.ServiceRecordConversation, "KI Chat: Zeiterfassung" },
{AiActionType.ServiceRecordDocumentation, "KI Doku: Zeiterfassung" }
};
public Control GetModalViewWindow(string title, Control control, double height = 600, double width = 1200)
@@ -69,9 +64,9 @@ namespace BeWo.Services
return "GKV-Abrechnung Nr. " + vm.Oid;
}
public string GetAiTitle(AiContextType aiContextType)
public string GetAiTitle(AiActionType actionType)
{
if (_UIContext2Header.TryGetValue(aiContextType, out string str))
if (_UIContext2Header.TryGetValue(actionType, out string str))
return str;
return "default";

View File

@@ -81,7 +81,7 @@ namespace BeWo.Services
public void ShowAiConversationWindow(AiConversationChatViewModel viewModel)
{
var control = _controlFactory.GetAiConversationControl(viewModel);
var title = _windowFactory.GetAiTitle(viewModel.AiContext);
var title = _windowFactory.GetAiTitle(viewModel.ActionType);
var options = new BeWoWindowOptions()
{
Height = 600,

View File

@@ -2,11 +2,16 @@
x:Class="BeWo.View.Controls.AI.AiChatButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ai="clr-namespace:BeWo.ViewModel.Controls.AI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:draw="clr-namespace:System.Drawing;assembly=System.Drawing"
xmlns:i="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:local="clr-namespace:BeWo.View.Controls.AI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ai="clr-namespace:BeWo.ViewModel.Controls.AI" xmlns:i="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" d:DataContext="{d:DesignInstance Type=ai:AiChatButtonViewModel}"
mc:Ignorable="d">
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DataContext="{d:DesignInstance Type=ai:AiChatButtonWithHistoryViewModel}"
mc:Ignorable="d"
Loaded="UserControl_Loaded"
Visibility="{Binding IsEnabled, Converter={StaticResource BoolVisibilityConverter}}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -26,9 +31,9 @@
Background="Transparent"
Content="{StaticResource AiDesignsIconKIChatWeissOrange}"
ToolTip="KI Chat öffnen"
ToolTipService.ShowOnDisabled="True" >
ToolTipService.ShowOnDisabled="True">
<Button.InputBindings>
<MouseBinding Command="{Binding OpenConversationPopupCommand}" Gesture="LeftClick"/>
<MouseBinding Command="{Binding OpenConversationPopupCommand}" Gesture="LeftClick" />
</Button.InputBindings>
</Button>
<Button
@@ -37,9 +42,9 @@
Margin="10,0,0,0"
Background="Transparent"
Content="{StaticResource AiDesignsIconKIFunktionWeissGruen}"
MouseRightButtonUp="btnOpenAi5_MouseRightButtonUp"
ToolTip="KI Chat mit Prompt-Baustein starten"
ToolTipService.ShowOnDisabled="True"
MouseRightButtonUp="btnOpenAi5_MouseRightButtonUp">
ToolTipService.ShowOnDisabled="True">
<Button.InputBindings>
<MouseBinding Command="{Binding OpenAllPromptsPopupCommand}" Gesture="LeftClick" />
</Button.InputBindings>
@@ -57,6 +62,22 @@
Es können keine neuen Chats zu dieser Ansicht erstellt werden.
</Image.ToolTip>
</Image>
<StackPanel
Orientation="Horizontal"
Visibility="{Binding IsHistoryEnabled, Converter={StaticResource BoolVisibilityConverter}}">
<Button
x:Name="btn_AiPromptbausteinUndo"
Margin="3,0,0,0"
Command="{Binding UndoAiActionCommand}"
Style="{StaticResource ButtonPreviousStyle}"
Visibility="{Binding IsUndoButtonVisible, Converter={StaticResource BoolVisibilityHiddenConverter}}" />
<Button
x:Name="btn_AiPromptbausteinRedo"
Margin="3,0,3,0"
Command="{Binding RedoAiActionCommand}"
Style="{StaticResource ButtonRedoStyle}"
Visibility="{Binding IsRedoButtonVisible, Converter={StaticResource BoolVisibilityHiddenConverter}}" />
</StackPanel>
</StackPanel>
<!--<Popup
x:Name="popup_promptbaustein_all"
@@ -69,10 +90,10 @@
</Popup>-->
<Popup
x:Name="popup_promptbaustein_favoriten"
IsOpen="{Binding IsFavoritenOpen}"
Placement="Top"
PlacementTarget="{Binding ElementName=btnOpenAi5}"
StaysOpen="False"
IsOpen="{Binding IsFavoritenOpen}">
StaysOpen="False">
<Border x:Name="border_promptbaustein_favoriten" BorderThickness="1" />
</Popup>
</Grid>

View File

@@ -27,15 +27,6 @@ namespace BeWo.View.Controls.AI
/// </summary>
public partial class AiChatButton : UserControl
{
public static readonly DependencyProperty ActionTypeProperty =
DependencyProperty.Register("ActionType", typeof(AiActionType), typeof(AiChatButton), new PropertyMetadata(AiActionType.ServiceRecord, OnActionTypeChanged));
public AiActionType ActionType
{
get { return (AiActionType)GetValue(ActionTypeProperty); }
set { SetValue(ActionTypeProperty, value); }
}
public AiChatButtonViewModel ViewModel => DataContext as AiChatButtonViewModel;
public AiChatButton()
@@ -43,25 +34,17 @@ namespace BeWo.View.Controls.AI
InitializeComponent();
}
private static void OnActionTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
var control = (AiChatButton)d;
var actionType = (AiActionType)e.NewValue;
if (BeWoApp.AppSettings.ShowAI && BeWoApp.HasLoggedOnUserRight(UserRightType.AiModulePromptbausteineView))
if (ViewModel.IsEnabled)
{
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiPromptbausteinFolder(actionType), folders => control.InitPromptbausteine(actionType, folders));
}
}
var actionType = ViewModel.ActionType;
public void AiPromptOpenAll()
{
//popup_promptbaustein_all.IsOpen = true;
//OpenAiPromptClick?.Invoke(this, e);
BeWoApp.MainControl.WindowService.Show(ViewModel.AllPromptsViewModel);
}
public void AiPromptOpenFavorite()
{
popup_promptbaustein_favoriten.IsOpen = true;
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiPromptbausteinFolder(actionType), folders => InitPromptbausteine(actionType, folders),
null,
true,
this);
}
}
private void InitPromptbausteine(AiActionType actionType, List<AiPromptbausteinFolderDC> folders)

View File

@@ -5,8 +5,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="root"
d:DesignWidth="28"
d:DesignHeight="28"
d:DesignWidth="28"
mc:Ignorable="d">
<Button
x:Name="btn"
@@ -14,10 +14,10 @@
Height="22"
Padding="0"
Click="btn_Click"
ToolTip="{Binding HelpToolTip, ElementName=root}"
Cursor="Hand"
FontSize="13"
FontWeight="Bold"
FontSize="13">
ToolTip="{Binding HelpToolTip, ElementName=root}">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
@@ -25,9 +25,7 @@
Fill="White"
Stroke="#FF14549E"
StrokeThickness="1" />
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
@@ -40,11 +38,11 @@
</ControlTemplate>
</Button.Template>
<TextBlock
Text="?"
Foreground="#FF14549E"
FontWeight="Bold"
FontSize="14"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
VerticalAlignment="Center"
FontSize="14"
FontWeight="Bold"
Foreground="#FF14549E"
Text="?" />
</Button>
</UserControl>

View File

@@ -292,8 +292,6 @@ namespace BeWo.View.Detail
#endif
}
public DelegateCommand OpenAiWindowCommand { get; }
public Dictionary<TableID, long[]> GetVisibleInformationReferences()
{
var visible = ViewModel;
@@ -312,13 +310,14 @@ namespace BeWo.View.Detail
private AiConversationChatViewModel getAiConversationChatViewModel()
{
var customer_oid = ViewModel.DataContract.CustomerOid;
var context = GetVisibleInformationReferences();
throw new NotImplementedException();
//var customer_oid = ViewModel.DataContract.CustomerOid;
//var context = GetVisibleInformationReferences();
var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerDetail, context, customer_oid);
// var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerDetail, context, customer_oid);
return vm;
}
// return vm;
}
private void OpenAiWindow()
{

View File

@@ -2,6 +2,7 @@
x:Class="BeWo.View.Detail.Zeiterfassung.ServiceRecordEditView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ai="clr-namespace:BeWo.View.Controls.AI"
xmlns:core="clr-namespace:BS.Shared.Core;assembly=BS.Shared"
xmlns:detail="clr-namespace:BeWo.View.Detail"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
@@ -16,7 +17,6 @@
xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls"
xmlns:val="clr-namespace:BeWo.Validation"
xmlns:zeit="clr-namespace:BeWo.View.Detail.Zeiterfassung"
xmlns:ai="clr-namespace:BeWo.View.Controls.AI"
x:Name="root"
Width="Auto"
Height="Auto"
@@ -1508,12 +1508,11 @@
<StackPanel
x:Name="stackpanel_ai"
Grid.Row="1"
Grid.ColumnSpan="2"
Grid.ColumnSpan="2"
Margin="3,3,3,6"
HorizontalAlignment="Right"
DataContext=""
Orientation="Horizontal"
Visibility="{Binding IsAiDocuButtonVisible, Converter={StaticResource BoolVisibilityConverter}}">
Orientation="Horizontal">
<StackPanel.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -1521,25 +1520,8 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</StackPanel.Resources>
<Button
x:Name="btn_AiPromptbausteinUndo"
Margin="3,0,0,0"
Command="{Binding UndoEditAiActionCommand}"
Style="{StaticResource ButtonPreviousStyle}"
Visibility="{Binding IsEditUndoButtonVisible, Converter={StaticResource BoolVisibilityHiddenConverter}}" />
<Button
x:Name="btn_AiPromptbausteinRedo"
Margin="3,0,3,0"
Command="{Binding RedoEditAiActionCommand}"
Style="{StaticResource ButtonRedoStyle}"
Visibility="{Binding IsEditRedoButtonVisible, Converter={StaticResource BoolVisibilityHiddenConverter}}" />
<ai:AiPromptbausteinButton
Margin="3,0,0,0"
x:Name="btn_AiPromptbaustein"
ActionType="ServiceRecordDocumentation"
CanExecute="{Binding EditVM.Notice, Converter={StaticResource StringEmptyBoolConverter}}"
ItemAccepted="btn_AiPromptbaustein_ItemAccepted" />
<ai:AiChatButton
x:Name="btn_ai_docu" />
</StackPanel>

View File

@@ -26,6 +26,7 @@ using DevExpress.Xpf.Editors;
using DevExpress.Xpf.RichEdit;
using SupportConceptService = BeWo.Core.Service.SupportConceptService;
using System.Windows.Media;
using BeWo.ViewModel.Controls.AI;
namespace BeWo.View.Detail.Zeiterfassung
{
@@ -1168,9 +1169,10 @@ namespace BeWo.View.Detail.Zeiterfassung
}
}
}
private void btn_AiPromptbaustein_ItemAccepted(object sender, AbstractBaseVM e)
{
ViewModel.ItemAccepted(sender, e);
}
public void SetAiViewmodel(AiChatButtonWithHistoryViewModel aiChatButtonWithHistoryView)
{
btn_ai_docu.DataContext = aiChatButtonWithHistoryView;
}
}
}

View File

@@ -1730,7 +1730,7 @@
ActionType="ServiceRecordDocumentation"
CanExecute="{Binding PrototypeVM.Notice, Converter={StaticResource StringEmptyBoolConverter}}"
ItemAccepted="btn_AiPromptbaustein2_ItemAccepted" />-->
<ai:AiChatButton x:Name="btn_ai_docu" ActionType="ServiceRecordDocumentation" />
<ai:AiChatButton x:Name="btn_ai_docu" />
<!--</StackPanel>-->
@@ -3335,7 +3335,7 @@
Margin="0"
VerticalAlignment="Center"
Orientation="Horizontal">
<ai:AiChatButton x:Name="btn_ai_conv" ActionType="ServiceRecordConversation" />
<ai:AiChatButton x:Name="btn_ai_conv" />
<!--<ai:AiConversationButton
x:Name="ai_conversation_btn"
Margin="10,0,0,0"

View File

@@ -54,6 +54,7 @@ using BeWo.View.Windows;
using BeWo.Core.Commands;
using BeWo.ViewModel.View.AI;
using System.Text;
using BS.Shared.DataContracts.Feature.AI;
namespace BeWo.View.Detail.Zeiterfassung
{
@@ -348,14 +349,11 @@ namespace BeWo.View.Detail.Zeiterfassung
srGridControl.ItemsSourceChanged += SrGridControl_ItemsSourceChanged;
btn_ai_conv.DataContext = pViewModel.AiChatButtonConversationViewModel;
btn_ai_conv.ViewModel.GetAiConversationChatViewModel = () => getAiConversationChatViewModel();
btn_ai_conv.ViewModel.GetAiVisualContext = () => getAiVisualContext();
btn_ai_docu.DataContext = pViewModel.AiChatButtonDocumentationViewModel;
}
public ICommand OpenAiWindowCommand { get; set; }
public ICommand OpenAiChatPromptWindowCommand { get; set; }
private void SrGridControl_ItemsSourceChanged(object sender, DevExpress.Xpf.Grid.ItemsSourceChangedEventArgs e)
{
ErstelleRecordInformationString();
@@ -1184,16 +1182,20 @@ namespace BeWo.View.Detail.Zeiterfassung
BeWoView serviceRecordEditView;
if (vm.GroupOid != null)
ViewModel.AiChatButtonDocumentationEditViewModel.ClearHistory();
if (vm.GroupOid != null)
{
serviceRecordEditView = new ServiceRecordGroupEditView();
}
else
{
serviceRecordEditView = new ServiceRecordEditView();
}
var view = new ServiceRecordEditView();
ViewModel.AiChatButtonDocumentationEditViewModel.ClearHistory();
view.SetAiViewmodel(ViewModel.AiChatButtonDocumentationEditViewModel);
serviceRecordEditView = view;
}
popup_content.Child = serviceRecordEditView;
@@ -5082,21 +5084,19 @@ namespace BeWo.View.Detail.Zeiterfassung
ComboBoxTreeViewControl.TreeViewSourceList = ViewModel.PrototypeVM.GoalTree;
}
private AiConversationChatViewModel getAiConversationChatViewModel()
{
private AiViewContextDC getAiVisualContext()
{
var records = GetVisibleRecordVMs();
var context = ViewModel.GetVisibleInformationReferences(records);
var oid = supportConceptSelectionControl.SelectedItem.SupportConceptTreeNodeDC.SupportConcept.SupportConceptOid;
var canSendNewMessage = ViewModel.AiConversationButtonState == Controls.AI.AiConversationButtonState.Normal;
var oid = supportConceptSelectionControl.SelectedItem.SupportConceptTreeNodeDC.SupportConcept.SupportConceptOid;
var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.ServiceRecord, context, oid, canSendNewMessage);
var dc = new AiViewContextDC()
{
Primary = oid,
References = context
};
return vm;
}
private void OpenAiWindow()
{
MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel());
return dc;
}
private IEnumerable<ServiceRecordVM> GetVisibleRecordVMs()
@@ -5123,16 +5123,6 @@ namespace BeWo.View.Detail.Zeiterfassung
return list;
}
private void ItemAccepted(object sender, AbstractBaseVM e)
{
ViewModel.ItemAccepted(sender, e);
}
private void btn_AiPromptbaustein2_ItemAccepted(object sender, AbstractBaseVM e)
{
ViewModel.ItemAccepted(sender, e);
}
}
//public class RowBackgroundHelper

View File

@@ -235,11 +235,12 @@ namespace BeWo.View.Navigation
private AiConversationChatViewModel getAiConversationChatViewModel()
{
var context = GetVisibleInformationReferences();
throw new NotImplementedException();
// var context = GetVisibleInformationReferences();
var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerNavigation, context);
// var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerNavigation, context);
return vm;
// return vm;
}
private void OpenAiWindow()

View File

@@ -110,11 +110,12 @@ namespace BeWo.View.Navigation
private AiConversationChatViewModel getAiConversationChatViewModel()
{
var context = GetVisibleInformationReferences();
throw new NotImplementedException();
//var context = GetVisibleInformationReferences();
var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.EmployeeNavigation, context);
//var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.EmployeeNavigation, context);
return vm;
//return vm;
}
private void OpenAiWindow()

View File

@@ -267,24 +267,6 @@
Click="btnDelete_Click"
Content="Löschen"
Style="{StaticResource NavigationToolbarButtonStyle}" />
<StackPanel
Margin="0"
Orientation="Horizontal"
Visibility="Collapsed">
<StackPanel.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\..\Styles\ModernOrangeBlack.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</StackPanel.Resources>
<Button
x:Name="btnOpenAi2"
Margin="10,0,0,0"
Command="{Binding Path=OpenAiWindowCommand, RelativeSource={RelativeSource AncestorType={x:Type localView:BeWoView}}}"
Content="AI Chat Window"
Style="{StaticResource NavigationToolbarButtonStyle}" />
</StackPanel>
<TextBlock
x:Name="textblock_link"
Margin="20,0,0,0"

View File

@@ -86,8 +86,6 @@ namespace BeWo.View.Navigation
OpenSelectedObject();
}
};
OpenAiWindowCommand = new DelegateCommand(null, () => false);
}
public delegate bool ArchiveObjectDelegate(IFilterableDC obj);
@@ -128,8 +126,6 @@ namespace BeWo.View.Navigation
public event CopyObjectDelegate CopyObject;
public DelegateCommand OpenAiWindowCommand { get; set; }
public bool ArchiveButtonVisible
{
get

View File

@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -76,11 +77,12 @@ namespace BeWo.View.Navigation
private AiConversationChatViewModel getAiConversationChatViewModel()
{
var context = GetVisibleInformationReferences();
throw new NotImplementedException();
//var context = GetVisibleInformationReferences();
var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.OrganisationNavigation, context);
//var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.OrganisationNavigation, context);
return vm;
//return vm;
}
private void OpenAiWindow()

View File

@@ -24,6 +24,7 @@ using DevExpress.XtraBars.Docking;
using BeWo.ViewModel.View.AI;
using DevExpress.Xpf.Editors;
using BS.Shared.Translation;
using System;
namespace BeWo.View.Navigation
{
@@ -151,11 +152,12 @@ namespace BeWo.View.Navigation
private AiConversationChatViewModel getAiConversationChatViewModel()
{
var context = GetVisibleInformationReferences();
throw new NotImplementedException();
//var context = GetVisibleInformationReferences();
var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.PersonNavigation, context);
//var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.PersonNavigation, context);
return vm;
//return vm;
}
private void OpenAiWindow()

View File

@@ -227,11 +227,13 @@ namespace BeWo.View.Navigation
private AiConversationChatViewModel getAiConversationChatViewModel()
{
var context = GetVisibleInformationReferences();
throw new NotImplementedException();
var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.SupportConceptNavigation, context);
//var context = GetVisibleInformationReferences();
return vm;
//var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.SupportConceptNavigation, context);
//return vm;
}
private void OpenAiWindow()

View File

@@ -73,7 +73,7 @@ namespace BeWo.ViewModel
public string Context => DataContract.Context;
public Dictionary<TableID, long[]> ContextBeWoObjects => DataContract.ContextBeWoObjects;
public AiDataContextType Context_Type => DataContract.ContextType;
public UIContext UIContext => (UIContext)DataContract.UIContext;
public AiActionType AiActionType => DataContract.ActionType;
protected override void InitByDataContract(AiConversationDC pDataContract)
{

View File

@@ -1,29 +1,51 @@
using BeWo.ViewModel.View.AI;
using BeWo.ServiceProxy;
using BeWo.View.Controls.AI;
using BeWo.View.Detail.AI;
using BeWo.ViewModel.View.AI;
using BS.Shared;
using BS.Shared.DataContracts.Feature.AI;
using DevExpress.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace BeWo.ViewModel.Controls.AI
{
public enum AiChatButtonState
{
Hidden,
Normal,
Loading,
Warning,
Disabled
}
public class AiChatButtonViewModel : AbstractBaseVM
{
private bool canExecute;
private AiChatButtonState buttonState;
public AiActionType ActionType { get; protected set; }
public bool IsFavoritenOpen { get; set; }
public List<AiMenuItemTemplate> AssistentCommands { get; protected set; }
public virtual bool IsHistoryEnabled => false;
public bool IsEnabled => BeWoApp.AppSettings.ShowAI && BeWoApp.HasLoggedOnUserRight(GetUserRightType());
public bool CanExecute
{
get => canExecute;
set => SetProperty(ref canExecute, value, nameof(CanExecute));
}
public AiChatButtonState ButtonState
{
get => buttonState;
set => SetProperty(ref buttonState, value, nameof(ButtonState));
}
public Func<AiConversationChatViewModel> GetAiConversationChatViewModel { get; set; }
public Func<AiViewContextDC> GetAiVisualContext { get; set; }
public AiPromptbausteinSelectionComplexViewModel AllPromptsViewModel { get; set; }
@@ -31,8 +53,13 @@ namespace BeWo.ViewModel.Controls.AI
public DelegateCommand OpenAllPromptsPopupCommand { get; protected set; }
public DelegateCommand OpenFavoritePromptsPopupCommand { get; protected set; }
public AiChatButtonViewModel()
public AiChatButtonViewModel(AiActionType aiActionType)
{
ActionType = aiActionType;
if (!IsEnabled)
return;
canExecute = true;
OpenConversationPopupCommand = new DelegateCommand(OpenConversationPopup);
@@ -40,21 +67,67 @@ namespace BeWo.ViewModel.Controls.AI
OpenFavoritePromptsPopupCommand = new DelegateCommand(OpenFavoritePromptsPopup);
}
public void OpenConversationPopup()
public void CheckContextSize()
{
BeWoApp.MainControl.WindowService.ShowAiConversationWindow(GetAiConversationChatViewModel());
if (!IsEnabled)
{
return;
}
ButtonState = AiChatButtonState.Loading;
var context = GetAiVisualContext();
if (context != null)
{
var context2 = context.References.ToDictionary(kv => kv.Key, kv => kv.Value.ToList());
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.CheckContextSize(ActionType, context2, null),
isValid =>
{
if (isValid)
ButtonState = AiChatButtonState.Normal;
else
ButtonState = AiChatButtonState.Warning;
},
(exp) => ButtonState = AiChatButtonState.Disabled);
}
}
public void OpenAllPromptsPopup()
private void OpenConversationPopup()
{
var context = GetAiVisualContext();
var chat_viewmodel = VMFactory.CreateAiConversationChatViewModel(ActionType, context.References, (long)context.Primary, true);
BeWoApp.MainControl.WindowService.Show(chat_viewmodel);
}
private void OpenAllPromptsPopup()
{
BeWoApp.MainControl.WindowService.Show(AllPromptsViewModel);
}
public void OpenFavoritePromptsPopup()
private void OpenFavoritePromptsPopup()
{
IsFavoritenOpen = true;
FirePropertyChanged(nameof(IsFavoritenOpen));
}
private UserRightType GetUserRightType()
{
switch (ActionType)
{
case AiActionType.ServiceRecord:
break;
case AiActionType.ServiceRecordConversation:
return UserRightType.AiModuleServiceRecordChat;
case AiActionType.ServiceRecordDocumentation:
return UserRightType.AiModuleServiceRecordDocu;
default:
break;
}
throw new InvalidOperationException($"UserRightType '{ActionType}' not implemented");
}
}
public class AiMenuItemTemplate

View File

@@ -1,4 +1,7 @@
using System;
using BS.Shared;
using DevExpress.Mvvm;
using DevExpress.XtraPrinting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -19,12 +22,15 @@ namespace BeWo.ViewModel.Controls.AI
set => SetProperty(ref currentValue, value, nameof(CurrentValue));
}
public override bool IsHistoryEnabled => true;
public bool IsUndoButtonVisible => CurrentIndex > 0;
public bool IsRedoButtonVisible => CurrentIndex < History.Count - 1;
public override bool IsHistoryEnabled => true;
public DelegateCommand UndoAiActionCommand { get; protected set; }
public DelegateCommand RedoAiActionCommand { get; protected set; }
public AiChatButtonWithHistoryViewModel() : base()
public AiChatButtonWithHistoryViewModel(AiActionType aiActionType) : base(aiActionType)
{
History = new List<string>();
CurrentIndex = 0;
@@ -32,17 +38,19 @@ namespace BeWo.ViewModel.Controls.AI
{
new AiMenuItemTemplate()
{
Command = new DevExpress.Mvvm.DelegateCommand<AiConversationMessageVM>(x => Accept1(x.Message)),
Command = new DelegateCommand<AiConversationMessageVM>(x => AddValue(x.Message)),
Icon = null,
Name = "Akzeptieren"
Name = "Anfügen"
},
new AiMenuItemTemplate()
{
Command = new DevExpress.Mvvm.DelegateCommand<AiConversationMessageVM>(x => Accept2(x.Message)),
Command = new DelegateCommand<AiConversationMessageVM>(x => ReplaceValue(x.Message)),
Icon = null,
Name = "Ersetzen"
},
};
UndoAiActionCommand= new DelegateCommand(UndoAiAction);
RedoAiActionCommand= new DelegateCommand(RedoAiAction);
}
public void ClearHistory()
@@ -97,14 +105,24 @@ namespace BeWo.ViewModel.Controls.AI
CurrentValue = History[CurrentIndex];
}
public void Accept1(string s)
public void AddValue(string s)
{
var sb = new StringBuilder();
sb.AppendLine("Antwort:");
sb.AppendLine(s);
sb.AppendLine();
sb.AppendLine("Original:");
sb.AppendLine(CurrentValue);
var str = sb.ToString();
Accept(str);
}
public void Accept2(string s)
public void ReplaceValue(string str)
{
Accept(str);
}
}
}

View File

@@ -90,7 +90,7 @@ namespace BeWo.ViewModel.ListViewModel
Displayname = "Displayname Megamegalange Deluxe Op 3000",
Messages = messages_dc,
Modell = model,
UIContext = AiContextType.ServiceRecord,
ActionType = AiActionType.ServiceRecordDocumentation,
Updated = DateTime.Now,
};
@@ -116,7 +116,7 @@ namespace BeWo.ViewModel.ListViewModel
Created = DateTime.Now,
Displayname = "Dummy Num " + i.ToString(),
Modell = model,
UIContext = AiContextType.ServiceRecord,
ActionType = AiActionType.ServiceRecordDocumentation,
Updated = DateTime.Now,
};

View File

@@ -102,19 +102,6 @@ namespace BeWo.ViewModel.ListViewModel
//private static List<DarreichungsformDC> _AllDosageForms;
private List<string> _AiActionHistory;
private int _AiActionHistoryIndex;
private AiConversationButtonState _AiConversationButtonState;
public ICommand UndoAiActionCommand { get; set; }
public ICommand RedoAiActionCommand { get; set; }
private List<string> _EditAiActionHistory;
private int _EditAiActionHistoryIndex;
public ICommand UndoEditAiActionCommand { get; set; }
public ICommand RedoEditAiActionCommand { get; set; }
public AiUserSettingVM AiUserSetting { get; set; }
public AiChatButtonViewModel AiChatButtonConversationViewModel { get; set; }
@@ -193,17 +180,16 @@ namespace BeWo.ViewModel.ListViewModel
private void InitAiStuff()
{
AiChatButtonConversationViewModel = new AiChatButtonViewModel()
AiChatButtonConversationViewModel = new AiChatButtonViewModel(AiActionType.ServiceRecordConversation)
{
};
AiChatButtonDocumentationViewModel = new AiChatButtonWithHistoryViewModel()
};
AiChatButtonDocumentationViewModel = new AiChatButtonWithHistoryViewModel(AiActionType.ServiceRecordDocumentation)
{
};
AiChatButtonDocumentationEditViewModel = new AiChatButtonWithHistoryViewModel()
AiChatButtonDocumentationEditViewModel = new AiChatButtonWithHistoryViewModel(AiActionType.ServiceRecordDocumentation)
{
};
@@ -224,12 +210,6 @@ namespace BeWo.ViewModel.ListViewModel
FirePropertyChanged(nameof(AiUserSetting));
}
public AiConversationButtonState AiConversationButtonState
{
get => _AiConversationButtonState;
set => SetProperty(ref _AiConversationButtonState, value, nameof(AiConversationButtonState));
}
public IEnumerable<ServiceRecordVM> CurrentVisibleVMs { get; set; }
public string AktuellerDokutext
{
@@ -257,252 +237,11 @@ namespace BeWo.ViewModel.ListViewModel
public bool IsAiChatButtonVisible => SelectedCustomerNode is object && IsAiModuleEnabled && BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleServiceRecordChat);
public bool IsAiDocuButtonVisible => SelectedCustomerNode is object && IsAiModuleEnabled && BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleServiceRecordDocu);
public bool IsAiRowVisible => IsAiDocuButtonVisible || VoiceToTextButtonControl.HasRightToUseAIVoice;
public void ItemAccepted(object sender, AbstractBaseVM item)
{
if(item is AiPromptbausteinRoutineVM)
{
MessageBox.Show("");
return;
}
var prompt = item as AiPromptbausteinPromptVM;
if (prompt is null)
throw new NotImplementedException();
// 1. Information aufbereiten
// 1.1 Prompt
var prompt_oid = prompt.DataContract.Oid.Value;
var prompt_version = prompt.DataContract.Version;
// 1.2 Hilfeplan
var support_concept = SelectedCustomerNode.SupportConceptTreeNodeDC.SupportConcept;
var support_concept_oid = support_concept.SupportConceptOid;
var support_concept_version = support_concept.SupportConceptVersion;
// 1.3 Aktuelles Doku Feld
var doku_feld = AktuellerDokutext;
// 1.4 Sichtbaren Zeiterfassungseinträge
var service_records = CurrentVisibleVMs;
var sr_refs = service_records.Select(x => new BeWoRefDC(x.DataContract.ServiceRecordOid.Value, x.DataContract.ServiceRecordVersion));
// 1.5 Costbearer
var costbearer = SelectedCustomerNode.SupportConceptTreeNodeDC.CostBearer;
var cb_oid = costbearer.CostBearerOid.Value;
var cb_ver = costbearer.CostBearerVersion;
// Service Aufruf
var req = new AiFunctionDocRequest()
{
AiPromptbausteinPrompt = new BeWoRefDC(prompt_oid, prompt_version),
SupportConcept = new BeWoRefDC(support_concept_oid, support_concept_version),
ServiceRecords = sr_refs,
CostBearer = new BeWoRefDC(cb_oid, cb_ver),
Dokumentation = doku_feld,
};
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.ExecuteAiFunctionServiceRecordDocumentation(req),
callback =>
{
var viewModel = new AiPromptbausteinActionResultViewModel();
viewModel.Result = callback.Result;
viewModel.Accept_Button_Clicked += (s, e) =>
{
var sb = new StringBuilder();
sb.AppendLine("AI Antwort:");
sb.AppendLine(viewModel.Result);
sb.AppendLine();
sb.AppendLine("Original:");
sb.AppendLine(AktuellerDokutext);
var str = sb.ToString();
var idx = _AiActionHistoryIndex;
var count = _AiActionHistory.Count;
if (count - 1 > idx)
{
_AiActionHistory.RemoveRange(idx + 1, count - idx - 1);
}
if (AktuellerDokutext != _AiActionHistory[_AiActionHistoryIndex])
{
_AiActionHistory.Add(AktuellerDokutext);
_AiActionHistoryIndex++;
}
_AiActionHistory.Add(str);
_AiActionHistoryIndex++;
AktuellerDokutext = str;
};
viewModel.Replace_Button_Clicked += (s, e) =>
{
var str = viewModel.Result;
var idx = _AiActionHistoryIndex;
var count = _AiActionHistory.Count;
if (count - 1 > idx)
{
_AiActionHistory.RemoveRange(idx + 1, count - idx - 1);
}
if (AktuellerDokutext != _AiActionHistory[_AiActionHistoryIndex])
{
_AiActionHistory.Add(AktuellerDokutext);
_AiActionHistoryIndex++;
}
_AiActionHistory.Add(str);
_AiActionHistoryIndex++;
AktuellerDokutext = str;
};
viewModel.Retry_Button_Clicked += (s, e) =>
{
ItemAccepted(sender, prompt);
};
BeWoApp.MainControl.WindowService.Show(viewModel);
}
);
}
public void EditPromptAccepted(object sender, AiPromptbausteinPromptVM prompt)
{
if (prompt is null)
throw new NotImplementedException();
// 1. Information aufbereiten
// 1.1 Prompt
var prompt_oid = prompt.DataContract.Oid.Value;
var prompt_version = prompt.DataContract.Version;
// 1.2 Hilfeplan
var support_concept = SelectedCustomerNode.SupportConceptTreeNodeDC.SupportConcept;
var support_concept_oid = support_concept.SupportConceptOid;
var support_concept_version = support_concept.SupportConceptVersion;
// 1.3 Aktuelles Doku Feld
var doku_feld = AktuellerEditDokutext;
// 1.4 Sichtbaren Zeiterfassungseinträge
var service_records = CurrentVisibleVMs;
var sr_refs = service_records.Select(x => new BeWoRefDC(x.DataContract.ServiceRecordOid.Value, x.DataContract.ServiceRecordVersion));
// 1.5 Costbearer
var costbearer = SelectedCustomerNode.SupportConceptTreeNodeDC.CostBearer;
var cb_oid = costbearer.CostBearerOid.Value;
var cb_ver = costbearer.CostBearerVersion;
// Service Aufruf
var req = new AiFunctionDocRequest()
{
AiPromptbausteinPrompt = new BeWoRefDC(prompt_oid, prompt_version),
SupportConcept = new BeWoRefDC(support_concept_oid, support_concept_version),
ServiceRecords = sr_refs,
CostBearer = new BeWoRefDC(cb_oid, cb_ver),
Dokumentation = doku_feld,
};
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.ExecuteAiFunctionServiceRecordDocumentation(req),
callback =>
{
var viewModel = new AiPromptbausteinActionResultViewModel();
viewModel.Result = callback.Result;
viewModel.Accept_Button_Clicked += (s, e) =>
{
var sb = new StringBuilder();
sb.AppendLine("AI Antwort:");
sb.AppendLine(viewModel.Result);
sb.AppendLine();
sb.AppendLine("Original:");
sb.AppendLine(AktuellerEditDokutext);
var str = sb.ToString();
var idx = _EditAiActionHistoryIndex;
var count = _EditAiActionHistory.Count;
if (count - 1 > idx)
{
_EditAiActionHistory.RemoveRange(idx + 1, count - idx - 1);
}
if (AktuellerEditDokutext != _EditAiActionHistory[_EditAiActionHistoryIndex])
{
_EditAiActionHistory.Add(AktuellerEditDokutext);
_EditAiActionHistoryIndex++;
}
_EditAiActionHistory.Add(str);
_EditAiActionHistoryIndex++;
AktuellerEditDokutext = str;
};
viewModel.Replace_Button_Clicked += (s, e) =>
{
var str = viewModel.Result;
var idx = _EditAiActionHistoryIndex;
var count = _EditAiActionHistory.Count;
if (count - 1 > idx)
{
_EditAiActionHistory.RemoveRange(idx + 1, count - idx - 1);
}
if (AktuellerEditDokutext != _EditAiActionHistory[_EditAiActionHistoryIndex])
{
_EditAiActionHistory.Add(AktuellerEditDokutext);
_EditAiActionHistoryIndex++;
}
_EditAiActionHistory.Add(str);
_EditAiActionHistoryIndex++;
AktuellerEditDokutext = str;
};
viewModel.Retry_Button_Clicked += (s, e) =>
{
ItemAccepted(sender, prompt);
};
BeWoApp.MainControl.WindowService.Show(viewModel);
}
);
}
public void UpdateViewYearFilter(IEnumerable<ServiceRecordVM> enumerable)
{
if (!IsAiChatButtonVisible)
{
AiConversationButtonState = AiConversationButtonState.Hidden;
return;
}
AiConversationButtonState = AiConversationButtonState.Loading;
var context = GetVisibleInformationReferences(enumerable);
if (context != null)
{
var context2 = context.ToDictionary(kv => kv.Key, kv => kv.Value.ToList());
ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.CheckContextSize(AiContextType.ServiceRecord, context2, null),
isValid =>
{
if (isValid)
AiConversationButtonState = AiConversationButtonState.Normal;
else
AiConversationButtonState = AiConversationButtonState.Warning;
},
(exp) => AiConversationButtonState = AiConversationButtonState.Disabled);
}
AiChatButtonConversationViewModel.CheckContextSize();
AiChatButtonDocumentationViewModel.CheckContextSize();
}
public Dictionary<TableID, long[]> GetVisibleInformationReferences(IEnumerable<ServiceRecordVM> selected_records)

View File

@@ -912,12 +912,12 @@ namespace BeWo.ViewModel
einheit_vm_list.VMList.Sort(WohneinheitVM.Compare);
}
public static AiConversationChatViewModel CreateAiConversationChatViewModel(AiContextType uIContext, Dictionary<TableID, long[]> bewoObjects,
public static AiConversationChatViewModel CreateAiConversationChatViewModel(AiActionType actionType, Dictionary<TableID, long[]> bewoObjects,
long? reference_oid = null, bool canSendNewMessage = true)
{
var vm = new AiConversationChatViewModel();
vm.AiContext = uIContext;
vm.ActionType = actionType;
vm.ContextBeWoObjects = bewoObjects;
vm.ReferenceObjectOid = reference_oid;
vm.CanSendNewMessage = canSendNewMessage;
@@ -925,19 +925,19 @@ namespace BeWo.ViewModel
return vm;
}
public static AiConversationListVM CreateAiConversationListVM(AiContextType uIContext, long? reference_oid)
public static AiConversationListVM CreateAiConversationListVM(AiActionType actionType, long? reference_oid)
{
var list = ServiceFacade.DoAiEnhancedServiceSnyc(s => s.GetAiConversations(uIContext, reference_oid));
var list = ServiceFacade.DoAiEnhancedServiceSnyc(s => s.GetAiConversations(actionType, reference_oid));
list.Reverse();
return new AiConversationListVM(list);
}
public static void CreateAiConversationListVMAsync(AiContextType uIContext, long? reference_oid, Action<AiConversationListVM> callback)
public static void CreateAiConversationListVMAsync(AiActionType actionType, long? reference_oid, Action<AiConversationListVM> callback)
{
ServiceFacade.DoAiEnhancedServiceAsnyc(
s => s.GetAiConversations(uIContext, reference_oid),
s => s.GetAiConversations(actionType, reference_oid),
cb =>
{
cb.Reverse();

View File

@@ -163,7 +163,7 @@ namespace BeWo.ViewModel.View.AI
}
public bool IsNewConversationVisible => ListVM.SelectedVM is null;
public AiContextType AiContext { get; set; }
public AiActionType ActionType { get; set; }
public long? ReferenceObjectOid { get; set; }
public Dictionary<TableID, long[]> ContextBeWoObjects { get; set; }
@@ -200,7 +200,7 @@ namespace BeWo.ViewModel.View.AI
conv.Created = DateTime.Now;
conv.Updated = DateTime.Now;
conv.UIContext = AiContext;
conv.ActionType = ActionType;
conv.ContextBeWoObjects = ContextBeWoObjects;
conv.Messages = new List<AiConversationMessageDC>()
{
@@ -355,7 +355,7 @@ namespace BeWo.ViewModel.View.AI
}
private void ReloadConversations()
{
var ui_context = AiContext;
var ui_context = ActionType;
var reference = ReferenceObjectOid;
var list = VMFactory.CreateAiConversationListVM(ui_context, reference);