Repository navigation
Expand file tree
/
Copy pathPostProcessingWindow.xaml.cs
More file actions
61 lines (53 loc) · 2.12 KB
/
Copy pathPostProcessingWindow.xaml.cs
File metadata and controls
61 lines (53 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Windows;
using System.Windows.Controls;
namespace WhisperTyper
{
public partial class PostProcessingWindow : Window
{
public PostProcessingSettings Settings { get; private set; }
public PostProcessingWindow(PostProcessingSettings? currentSettings)
{
InitializeComponent();
Settings = currentSettings ?? new PostProcessingSettings();
LoadSettings();
}
private void LoadSettings()
{
ChkEnabled.IsChecked = Settings.Enabled;
ComboProvider.SelectedIndex = (int)Settings.Provider;
TxtEndpoint.Text = Settings.Endpoint;
TxtModel.Text = string.IsNullOrEmpty(Settings.Model) ? "Default" : Settings.Model;
TxtPrompt.Text = Settings.Prompt;
}
private void BtnSave_Click(object sender, RoutedEventArgs e)
{
Settings.Enabled = ChkEnabled.IsChecked == true;
Settings.Provider = (LlmProvider)ComboProvider.SelectedIndex;
Settings.Endpoint = TxtEndpoint.Text;
Settings.Model = TxtModel.Text == "Default" ? "" : TxtModel.Text;
Settings.Prompt = TxtPrompt.Text;
DialogResult = true;
Close();
}
private void BtnCancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}
private void ComboProvider_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (TxtEndpoint == null) return;
if (ComboProvider.SelectedIndex == 1) // Ollama
{
if (string.IsNullOrEmpty(TxtEndpoint.Text) || TxtEndpoint.Text.Contains("/v1/chat/completions"))
TxtEndpoint.Text = "http://localhost:11434/api/generate";
}
else if (ComboProvider.SelectedIndex == 2) // LM Studio
{
if (string.IsNullOrEmpty(TxtEndpoint.Text) || TxtEndpoint.Text.Contains("/api/generate"))
TxtEndpoint.Text = "http://localhost:1234/v1/chat/completions";
}
}
}
}