mirror of
https://github.com/tuxdotrs/highminded.git
synced 2025-08-23 08:01:03 +05:30
feat: add hot reload settings
This commit is contained in:
@@ -14,22 +14,11 @@ namespace highminded.ui.controls;
|
||||
public partial class ChatUserControl : UserControl
|
||||
{
|
||||
|
||||
// OpenAI
|
||||
private readonly OpenAI.Chat.ChatClient _client = null!;
|
||||
private readonly MarkdownPipeline _pipeline = null!;
|
||||
|
||||
public ChatUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_client = new ChatClient(
|
||||
model: InMemoryDb.Obj.settingsManager.Settings.Model,
|
||||
credential: new ApiKeyCredential(InMemoryDb.Obj.settingsManager.Settings.ApiKey),
|
||||
options: new OpenAIClientOptions
|
||||
{
|
||||
Endpoint = new Uri(InMemoryDb.Obj.settingsManager.Settings.ApiURL)
|
||||
});
|
||||
|
||||
_pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().UseColorCode().Build();
|
||||
}
|
||||
|
||||
@@ -44,7 +33,7 @@ public partial class ChatUserControl : UserControl
|
||||
PromptBox.Clear();
|
||||
|
||||
AsyncCollectionResult<StreamingChatCompletionUpdate> completionUpdates =
|
||||
_client.CompleteChatStreamingAsync(prompt);
|
||||
InMemoryDb.Obj.ChatClient.CompleteChatStreamingAsync(prompt);
|
||||
|
||||
var responseBuilder = new StringBuilder();
|
||||
|
||||
|
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using highminded.utils;
|
||||
|
||||
namespace highminded.ui.controls;
|
||||
@@ -15,16 +10,16 @@ public partial class SettingsUserControl : UserControl
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ModelTextBox.Text = InMemoryDb.Obj.settingsManager.Settings.Model;
|
||||
ApiUrlTextBox.Text = InMemoryDb.Obj.settingsManager.Settings.ApiURL;
|
||||
ApiKeyTextBox.Text = InMemoryDb.Obj.settingsManager.Settings.ApiKey;
|
||||
ModelTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.Model;
|
||||
ApiUrlTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ApiURL;
|
||||
ApiKeyTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ApiKey;
|
||||
}
|
||||
|
||||
private void SaveSettingsBtn_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
InMemoryDb.Obj.settingsManager.Settings.Model = ModelTextBox.Text;
|
||||
InMemoryDb.Obj.settingsManager.Settings.ApiURL= ApiUrlTextBox.Text;
|
||||
InMemoryDb.Obj.settingsManager.Settings.ApiKey = ApiKeyTextBox.Text;
|
||||
InMemoryDb.Obj.settingsManager.Save();
|
||||
InMemoryDb.Obj.SaveSettings(new AppSettings()
|
||||
{
|
||||
ApiKey = ApiKeyTextBox.Text, ApiURL = ApiUrlTextBox.Text, Model = ModelTextBox.Text
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user