mirror of
https://github.com/tuxdotrs/highminded.git
synced 2025-08-23 16:11:02 +05:30
feat: add custom prompt box for screenshots
This commit is contained in:
@@ -27,7 +27,6 @@ public partial class ChatUserControl : UserControl
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||||
var fileName = $"screenshot_{timestamp}.png";
|
var fileName = $"screenshot_{timestamp}.png";
|
||||||
var filePath = Path.Combine(Environment.CurrentDirectory, fileName);
|
var filePath = Path.Combine(Environment.CurrentDirectory, fileName);
|
||||||
@@ -41,8 +40,7 @@ public partial class ChatUserControl : UserControl
|
|||||||
List<ChatMessage> messages =
|
List<ChatMessage> messages =
|
||||||
[
|
[
|
||||||
new UserChatMessage(
|
new UserChatMessage(
|
||||||
ChatMessageContentPart.CreateTextPart(
|
ChatMessageContentPart.CreateTextPart(InMemoryDb.Obj.SettingsManager.Settings.ScreenshotPrompt),
|
||||||
"I'm attaching a screenshot of a problem. I want you to read it and give me the appropriate answer."),
|
|
||||||
ChatMessageContentPart.CreateImagePart(imageBytes, "image/png")
|
ChatMessageContentPart.CreateImagePart(imageBytes, "image/png")
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="highminded.ui.controls.SettingsUserControl">
|
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">
|
<StackPanel Grid.Row="0" Grid.Column="0">
|
||||||
<TextBlock Text="Model" />
|
<TextBlock Text="Model" />
|
||||||
@@ -23,6 +23,11 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
|
<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"/>
|
<Button Name="SaveSettingsBtn" Content="Save" Click="SaveSettingsBtn_OnClick"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
@@ -13,13 +13,15 @@ public partial class SettingsUserControl : UserControl
|
|||||||
ModelTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.Model;
|
ModelTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.Model;
|
||||||
ApiUrlTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ApiURL;
|
ApiUrlTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ApiURL;
|
||||||
ApiKeyTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ApiKey;
|
ApiKeyTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ApiKey;
|
||||||
|
ScreenshotPromptTextBox.Text = InMemoryDb.Obj.SettingsManager.Settings.ScreenshotPrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveSettingsBtn_OnClick(object? sender, RoutedEventArgs e)
|
private void SaveSettingsBtn_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
InMemoryDb.Obj.SaveSettings(new AppSettings()
|
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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -34,9 +34,7 @@ public class InMemoryDb
|
|||||||
|
|
||||||
public void SaveSettings(AppSettings settings)
|
public void SaveSettings(AppSettings settings)
|
||||||
{
|
{
|
||||||
SettingsManager.Settings.ApiKey = settings.ApiKey;
|
SettingsManager.Settings = settings;
|
||||||
SettingsManager.Settings.ApiURL = settings.ApiURL;
|
|
||||||
SettingsManager.Settings.Model = settings.Model;
|
|
||||||
SettingsManager.Save();
|
SettingsManager.Save();
|
||||||
InitOpenAIClient();
|
InitOpenAIClient();
|
||||||
}
|
}
|
||||||
|
@@ -9,13 +9,14 @@ public class AppSettings
|
|||||||
public string Model { get; set; }
|
public string Model { get; set; }
|
||||||
public string ApiURL { get; set; }
|
public string ApiURL { get; set; }
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
|
public string ScreenshotPrompt { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SettingsManager<T> where T : class, new()
|
public class SettingsManager<T> where T : class, new()
|
||||||
{
|
{
|
||||||
private readonly string _settingsPath;
|
private readonly string _settingsPath;
|
||||||
public T Settings { get; private set; }
|
public T Settings { get; internal set; }
|
||||||
|
|
||||||
public SettingsManager(string appName = "highminded")
|
public SettingsManager(string appName = "highminded")
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user