109 lines
2.5 KiB
C#
109 lines
2.5 KiB
C#
using BeWo.ServiceProxy;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
using BS.Shared.Extensions;
|
|
using DevExpress.Mvvm;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace BeWo.View.Detail
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für AiConversationChatView.xaml
|
|
/// </summary>
|
|
public partial class AiConversationChatView : BeWoView
|
|
{
|
|
public AiConversationChatView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
OpenAiSettingCommand = new DelegateCommand(OpenAiSetting);
|
|
ReloadConversationsCommand = new DelegateCommand(ReloadConversations);
|
|
ReloadModelsCommand = new DelegateCommand(ReloadModels);
|
|
}
|
|
|
|
public AiConversationChatView(object o) : this()
|
|
{
|
|
|
|
}
|
|
|
|
public AiConversationListVM ViewModel
|
|
{
|
|
get => DataContext as AiConversationListVM;
|
|
set => DataContext = value;
|
|
}
|
|
|
|
public DelegateCommand OpenAiSettingCommand { get; set; }
|
|
public DelegateCommand ReloadConversationsCommand { get; set; }
|
|
public DelegateCommand ReloadModelsCommand { get; set; }
|
|
|
|
private void BeWoView_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
ReloadModels();
|
|
ReloadConversations();
|
|
|
|
//if (Dispatcher.CheckAccess())
|
|
//{
|
|
// ReloadModels();
|
|
// ReloadConversations();
|
|
//}
|
|
//else
|
|
//{
|
|
// Dispatcher.BeginInvoke(new Action(() =>
|
|
// {
|
|
// ReloadModels();
|
|
// ReloadConversations();
|
|
// }));
|
|
//}
|
|
}
|
|
|
|
private void ReloadButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
ReloadConversations();
|
|
}
|
|
|
|
private void OpenAiSetting()
|
|
{
|
|
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) =>
|
|
{
|
|
ViewModel.Models.MakeEqualTo(x);
|
|
popup_settings.IsOpen = true;
|
|
}, true, this);
|
|
}
|
|
|
|
private void ReloadModels()
|
|
{
|
|
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) =>
|
|
{
|
|
ViewModel.Models.MakeEqualTo(x);
|
|
|
|
if (ViewModel.SelectedModel is null && ViewModel.Models.Any())
|
|
ViewModel.SelectedModel = ViewModel.Models.First();
|
|
|
|
}, true, this);
|
|
}
|
|
|
|
private void ReloadConversations()
|
|
{
|
|
var ui_context = ViewModel.UIContext;
|
|
|
|
ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiConversations(ui_context), (x) =>
|
|
{
|
|
var vms = new AiConversationListVM(x);
|
|
ViewModel.VMList.MakeEqualTo(vms.VMList);
|
|
}, true);
|
|
}
|
|
}
|
|
}
|