mirror of
https://github.com/tuxdotrs/highminded.git
synced 2025-08-23 08:01:03 +05:30
fix: async func not waiting
This commit is contained in:
@@ -25,25 +25,34 @@ public partial class ChatUserControl : UserControl
|
|||||||
|
|
||||||
public async void SendScreenshot()
|
public async void SendScreenshot()
|
||||||
{
|
{
|
||||||
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
try
|
||||||
var fileName = $"screenshot_{timestamp}.png";
|
{
|
||||||
var filePath = Path.Combine(Environment.CurrentDirectory, fileName);
|
|
||||||
|
|
||||||
var screenshot = await ScreenCapture.CaptureScreenAsync(filePath);
|
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||||
if (!screenshot) return;
|
var fileName = $"screenshot_{timestamp}.png";
|
||||||
|
var filePath = Path.Combine(Environment.CurrentDirectory, fileName);
|
||||||
|
|
||||||
using Stream imageStream = File.OpenRead(filePath);
|
var screenshot = await ScreenCapture.CaptureScreenAsync(filePath);
|
||||||
BinaryData imageBytes = BinaryData.FromStream(imageStream);
|
if (!screenshot) throw new Exception("Failed to capture screenshot");
|
||||||
|
|
||||||
List<ChatMessage> messages =
|
await using Stream imageStream = File.OpenRead(filePath);
|
||||||
[
|
var imageBytes = await BinaryData.FromStreamAsync(imageStream);
|
||||||
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.CreateImagePart(imageBytes, "image/png")
|
|
||||||
)
|
|
||||||
];
|
|
||||||
|
|
||||||
await ProcessChatStreamAsync(messages);
|
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.CreateImagePart(imageBytes, "image/png")
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
await ProcessChatStreamAsync(messages);
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
ResultBlock.Text = err.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void PromptBox_OnKeyDown(object? sender, KeyEventArgs e)
|
private async void PromptBox_OnKeyDown(object? sender, KeyEventArgs e)
|
||||||
|
Reference in New Issue
Block a user