feat: add custom prompt box for screenshots

This commit is contained in:
tux
2025-07-02 23:50:31 +05:30
parent 5683f7cce1
commit e07f507db1
5 changed files with 13 additions and 9 deletions

View File

@@ -27,7 +27,6 @@ public partial class ChatUserControl : UserControl
{
try
{
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
var fileName = $"screenshot_{timestamp}.png";
var filePath = Path.Combine(Environment.CurrentDirectory, fileName);
@@ -41,8 +40,7 @@ public partial class ChatUserControl : UserControl
List<ChatMessage> messages =
[
new UserChatMessage(
ChatMessageContentPart.CreateTextPart(
"I'm attaching a screenshot of a problem. I want you to read it and give me the appropriate answer."),
ChatMessageContentPart.CreateTextPart(InMemoryDb.Obj.SettingsManager.Settings.ScreenshotPrompt),
ChatMessageContentPart.CreateImagePart(imageBytes, "image/png")
)
];

View File

@@ -5,7 +5,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="highminded.ui.controls.SettingsUserControl">
<Grid Margin="15" RowSpacing="10" ColumnSpacing="10" RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="*,*">
<Grid Margin="15" RowSpacing="10" ColumnSpacing="10" RowDefinitions="Auto,Auto,Auto,Auto" ColumnDefinitions="*,*">
<StackPanel Grid.Row="0" Grid.Column="0">
<TextBlock Text="Model" />
@@ -23,6 +23,11 @@
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
<TextBlock Text="Screenshot Prompt" />
<TextBox Name="ScreenshotPromptTextBox" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2">
<Button Name="SaveSettingsBtn" Content="Save" Click="SaveSettingsBtn_OnClick"/>
</StackPanel>

View File

@@ -13,13 +13,15 @@ public partial class SettingsUserControl : UserControl
ModelTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.Model;
ApiUrlTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ApiURL;
ApiKeyTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ApiKey;
ScreenshotPromptTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ScreenshotPrompt;
}
private void SaveSettingsBtn_OnClick(object? sender, RoutedEventArgs e)
{
InMemoryDb.Obj.SaveSettings(new AppSettings()
{
ApiKey = ApiKeyTextBox.Text, ApiURL = ApiUrlTextBox.Text, Model = ModelTextBox.Text
ApiKey = ApiKeyTextBox.Text, ApiURL = ApiUrlTextBox.Text, Model = ModelTextBox.Text,
ScreenshotPrompt = ScreenshotPromptTextBox.Text
});
}
}

View File

@@ -34,9 +34,7 @@ public class InMemoryDb
public void SaveSettings(AppSettings settings)
{
SettingsManager.Settings.ApiKey = settings.ApiKey;
SettingsManager.Settings.ApiURL = settings.ApiURL;
SettingsManager.Settings.Model = settings.Model;
SettingsManager.Settings = settings;
SettingsManager.Save();
InitOpenAIClient();
}

View File

@@ -9,13 +9,14 @@ public class AppSettings
public string Model { get; set; }
public string ApiURL { get; set; }
public string ApiKey { get; set; }
public string ScreenshotPrompt { get; set; }
}
public class SettingsManager<T> where T : class, new()
{
private readonly string _settingsPath;
public T Settings { get; private set; }
public T Settings { get; internal set; }
public SettingsManager(string appName = "highminded")
{