@@ -19,11 +19,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GestureClassification", "sr
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Verdure.NotificationArea", "src\Verdure.NotificationArea\Verdure.NotificationArea.csproj", "{2DD1EED6-1778-41DF-9E0D-EC23C99416B4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronBot.Copilot", "ElectronBot.Copilot\ElectronBot.Copilot.csproj", "{066FC203-FAD3-46D9-95A9-30FB6AE41583}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronBot.Copilot", "src\ElectronBot.Copilot\ElectronBot.Copilot.csproj", "{066FC203-FAD3-46D9-95A9-30FB6AE41583}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWordKeyboard.DotNet", "HelloWordKeyboard.DotNet\HelloWordKeyboard.DotNet.csproj", "{D416CD59-E9AC-4726-9CDE-1D8A4F256A9B}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWordKeyboard.DotNet", "src\HelloWordKeyboard.DotNet\HelloWordKeyboard.DotNet.csproj", "{D416CD59-E9AC-4726-9CDE-1D8A4F256A9B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWordKeyboard.ConsoleApp", "HelloWordKeyboard.ConsoleApp\HelloWordKeyboard.ConsoleApp.csproj", "{BF25733C-E01B-4611-B8AA-97A853F3E8FD}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWordKeyboard.ConsoleApp", "src\HelloWordKeyboard.ConsoleApp\HelloWordKeyboard.ConsoleApp.csproj", "{BF25733C-E01B-4611-B8AA-97A853F3E8FD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
@@ -223,7 +223,7 @@ public partial class App : Application
|
||||
services.AddSingleton<IActionExpressionProviderFactory, ActionExpressionProviderFactory>();
|
||||
|
||||
services.AddTransient<TodoView>();
|
||||
services.AddSingleton<Hw75DynamicViewModel>();
|
||||
services.AddTransient<Hw75DynamicViewModel>();
|
||||
|
||||
services.AddSingleton<EmoticonActionFrameService>();
|
||||
|
||||
@@ -232,6 +232,8 @@ public partial class App : Application
|
||||
services.AddSingleton<PoseRecognitionService>();
|
||||
|
||||
|
||||
services.AddTransient<IChatbotClient, ChatGPTChatbotCustomClient>();
|
||||
|
||||
services.AddTransient<IChatbotClient, ChatGPTChatbotClient>();
|
||||
|
||||
services.AddTransient<IChatbotClient, TuringChatbotClient>();
|
||||
|
||||
|
After Width: | Height: | Size: 576 KiB |
@@ -30,6 +30,8 @@ public class Constants
|
||||
|
||||
public const string DefaultChatBotNameKey = "DefaultChatBotNameKey";
|
||||
|
||||
public const string DefaultChatGPTNameKey = "DefaultChatGPTNameKey";
|
||||
|
||||
public const string DefaultAudioNameKey = "DefaultAudioNameKey";
|
||||
|
||||
public const string CustomGestureAppConfigKey = "CustomGestureAppConfigKey";
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
<None Remove="Assets\flutter.png" />
|
||||
<None Remove="Assets\Font\SmileySans-Oblique.ttf" />
|
||||
<None Remove="Assets\Images\CustomViewDefault.jpg" />
|
||||
<None Remove="Assets\Images\Hw75CustomViewDefault.png" />
|
||||
<None Remove="Assets\model.onnx" />
|
||||
<None Remove="Assets\pig.ico" />
|
||||
<None Remove="ClockViews\CustomClockView.xaml" />
|
||||
@@ -254,7 +255,7 @@
|
||||
<PackageReference Include="Microsoft.AI.MachineLearning" Version="1.16.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231115000" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231219000" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.8.0.20230708" />
|
||||
<PackageReference Include="OpenCvSharp4.Windows" Version="4.8.0.20230708" />
|
||||
@@ -268,9 +269,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\HelloWordKeyboard.DotNet\HelloWordKeyboard.DotNet.csproj" />
|
||||
<ProjectReference Include="..\ElectronBot.Braincase.Core\Verdure.ElectronBot.Core.csproj" />
|
||||
<ProjectReference Include="..\ElectronBot.Copilot\ElectronBot.Copilot.csproj" />
|
||||
<ProjectReference Include="..\GestureClassification\GestureClassification.csproj" />
|
||||
<ProjectReference Include="..\HelloWordKeyboard.DotNet\HelloWordKeyboard.DotNet.csproj" />
|
||||
<ProjectReference Include="..\Mediapipe.Net\Mediapipe.Net.csproj" />
|
||||
<ProjectReference Include="..\Verdure.NotificationArea\Verdure.NotificationArea.csproj" />
|
||||
</ItemGroup>
|
||||
@@ -344,6 +346,9 @@
|
||||
<None Update="Assets\hand.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Update="Assets\Images\Hw75CustomViewDefault.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Update="Assets\MLModel1.zip">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
@@ -578,6 +578,20 @@ public class ElectronBotHelper
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CloseChatAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var speechAndTTSService = App.GetService<ISpeechAndTTSService>();
|
||||
await speechAndTTSService.ReleaseRecognizerAsync();
|
||||
//await speechAndTTSService.CancelAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private async void MediaPlayer_MediaEnded(MediaPlayer sender, object args)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -21,6 +21,9 @@ public class Hw75Helper
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string ViewName { get; set; } = "Hw75CustomView";
|
||||
|
||||
|
||||
public event EventHandler? UpdateDataToDeviceHandler;
|
||||
|
||||
private static Hw75Helper? _instance;
|
||||
@@ -68,13 +71,15 @@ public class Hw75Helper
|
||||
|
||||
var pixelBuffer = await renderTargetBitmap.GetPixelsAsync();
|
||||
|
||||
var dpi = App.MainWindow.GetDpiForWindow();
|
||||
|
||||
using var stream = new InMemoryRandomAccessStream();
|
||||
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);
|
||||
encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore,
|
||||
(uint)renderTargetBitmap.PixelWidth,
|
||||
(uint)renderTargetBitmap.PixelHeight,
|
||||
96,
|
||||
96,
|
||||
dpi,
|
||||
dpi,
|
||||
pixelBuffer.ToArray());
|
||||
|
||||
await encoder.FlushAsync();
|
||||
@@ -87,7 +92,6 @@ public class Hw75Helper
|
||||
x.Resize(128, 296);
|
||||
//x.Grayscale();
|
||||
});
|
||||
|
||||
var byteArray = image.EnCodeImageToBytes();
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Verdure.ElectronBot.Core.Helpers;
|
||||
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Streams;
|
||||
|
||||
@@ -19,7 +18,7 @@ public static class SettingsStorageExtensions
|
||||
public static async Task SaveAsync<T>(this StorageFolder folder, string name, T content)
|
||||
{
|
||||
var file = await folder.CreateFileAsync(GetFileName(name), CreationCollisionOption.ReplaceExisting);
|
||||
var fileContent = await Json.StringifyAsync(content);
|
||||
var fileContent = await Verdure.ElectronBot.Core.Helpers.Json.StringifyAsync(content);
|
||||
|
||||
await FileIO.WriteTextAsync(file, fileContent);
|
||||
}
|
||||
@@ -34,12 +33,12 @@ public static class SettingsStorageExtensions
|
||||
var file = await folder.GetFileAsync($"{name}.json");
|
||||
var fileContent = await FileIO.ReadTextAsync(file);
|
||||
|
||||
return await Json.ToObjectAsync<T>(fileContent);
|
||||
return await Verdure.ElectronBot.Core.Helpers.Json.ToObjectAsync<T>(fileContent);
|
||||
}
|
||||
|
||||
public static async Task SaveAsync<T>(this ApplicationDataContainer settings, string key, T value)
|
||||
{
|
||||
settings.SaveString(key, await Json.StringifyAsync(value));
|
||||
settings.SaveString(key, await Verdure.ElectronBot.Core.Helpers.Json.StringifyAsync(value));
|
||||
}
|
||||
|
||||
public static void SaveString(this ApplicationDataContainer settings, string key, string value)
|
||||
@@ -53,7 +52,7 @@ public static class SettingsStorageExtensions
|
||||
|
||||
if (settings.Values.TryGetValue(key, out obj))
|
||||
{
|
||||
return await Json.ToObjectAsync<T>((string)obj);
|
||||
return await Verdure.ElectronBot.Core.Helpers.Json.ToObjectAsync<T>((string)obj);
|
||||
}
|
||||
|
||||
return default;
|
||||
|
||||
@@ -35,16 +35,16 @@
|
||||
<TextBlock
|
||||
Margin="2"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="24"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="24"
|
||||
Foreground="Black"
|
||||
Text="{x:Bind ViewModel.Day, Mode=OneWay}" />
|
||||
<TextBlock
|
||||
Margin="2"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="24"
|
||||
Foreground="Black"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
Text="{x:Bind ViewModel.TodayWeek, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -52,9 +52,9 @@
|
||||
Margin="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="36"
|
||||
Foreground="Black"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
Text="{x:Bind ViewModel.TodayTime, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -65,9 +65,9 @@
|
||||
Margin="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Bottom"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="{x:Bind ViewModel.ClockTitleConfig.Hw75CustomContentFontSize, Mode=OneWay}"
|
||||
Foreground="Black"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
Text="{x:Bind ViewModel.ClockTitleConfig.Hw75CustomContent, Mode=OneWay}"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
|
||||
@@ -42,6 +42,17 @@
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
|
||||
<TextBlock
|
||||
Margin="0,4,0,4"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="Black"
|
||||
Text="五行"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
Margin="0,4,0,4"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
@@ -52,6 +63,16 @@
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
Margin="0,4,0,4"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="Black"
|
||||
Text="冲煞"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
|
||||
<TextBlock
|
||||
Margin="0,4,0,4"
|
||||
@@ -64,7 +85,7 @@
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
<!--<TextBlock
|
||||
Margin="0,4,0,4"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="18"
|
||||
@@ -73,6 +94,16 @@
|
||||
LineHeight="2"
|
||||
Text="{x:Bind ViewModel.YellowCalendarResult.Yi, Mode=OneWay}"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />-->
|
||||
|
||||
<TextBlock
|
||||
Margin="0,4,0,4"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="Black"
|
||||
Text="凶神宜忌"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
@@ -84,6 +115,15 @@
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
Margin="0,4,0,4"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="Black"
|
||||
Text="忌"
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
<TextBlock
|
||||
Margin="0,4,0,4"
|
||||
FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans"
|
||||
|
||||
@@ -41,6 +41,11 @@ public class CustomClockTitleConfig
|
||||
get; set;
|
||||
} = string.Empty;
|
||||
|
||||
public string OpenAIBaseUrl
|
||||
{
|
||||
get; set;
|
||||
} = "https://api.openai-proxy.com/";
|
||||
|
||||
/// <summary>
|
||||
/// 手势识别回复文本
|
||||
/// </summary>
|
||||
@@ -59,7 +64,7 @@ public class CustomClockTitleConfig
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = string.Empty;
|
||||
} = "ms-appx:///Assets/Images/Hw75CustomViewDefault.png";
|
||||
|
||||
public float GaussianBlurValue
|
||||
{
|
||||
@@ -90,4 +95,14 @@ public class CustomClockTitleConfig
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string Hw75ViewName
|
||||
{
|
||||
get; set;
|
||||
} = "Hw75CustomView";
|
||||
|
||||
public string ChatGPTVersion
|
||||
{
|
||||
get; set;
|
||||
} = "gpt-3.5-turbo";
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<Identity
|
||||
Name="37619DC86D31F.44602C779CD56"
|
||||
Publisher="CN=829B8DD1-2BF4-465F-8663-BB54D1109ED6"
|
||||
Version="1.7.0.0" />
|
||||
Version="1.7.3.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>电子脑壳</DisplayName>
|
||||
|
||||
@@ -3,7 +3,10 @@ using ChatGPTSharp;
|
||||
using Contracts.Services;
|
||||
using ElectronBot.Braincase;
|
||||
using ElectronBot.Braincase.Contracts.Services;
|
||||
using ElectronBot.Braincase.Helpers;
|
||||
using ElectronBot.Braincase.Models;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.SemanticKernel.ChatCompletion;
|
||||
|
||||
namespace Services;
|
||||
public class ChatGPTChatbotClient : IChatbotClient
|
||||
@@ -12,6 +15,8 @@ public class ChatGPTChatbotClient : IChatbotClient
|
||||
|
||||
private readonly ILocalSettingsService _localSettingsService;
|
||||
|
||||
private Kernel? _kernel;
|
||||
|
||||
private ChatGPTClient? _chatGptClient;
|
||||
public ChatGPTChatbotClient(ILocalSettingsService localSettingsService)
|
||||
{
|
||||
@@ -27,10 +32,50 @@ public class ChatGPTChatbotClient : IChatbotClient
|
||||
throw new Exception("配置为空");
|
||||
}
|
||||
|
||||
_chatGptClient ??= new ChatGPTClient(result.ChatGPTSessionKey, "gpt-3.5-turbo");
|
||||
|
||||
var msg = await _chatGptClient.SendMessage(message);
|
||||
_kernel ??= Kernel.CreateBuilder()
|
||||
.AddOpenAIChatCompletion(result.ChatGPTVersion, result.ChatGPTSessionKey)
|
||||
.Build();
|
||||
|
||||
return msg.Response ?? "";
|
||||
var chat = _kernel.GetRequiredService<IChatCompletionService>()
|
||||
?? throw new KernelException("not init chat");
|
||||
|
||||
var resMessage = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var history = new ChatHistory();
|
||||
history.AddMessage(AuthorRole.User, message);
|
||||
var response = chat.GetStreamingChatMessageContentsAsync(history);
|
||||
await foreach (var item in response)
|
||||
{
|
||||
resMessage += item;
|
||||
//streamHandler?.Invoke(resMessage);
|
||||
}
|
||||
});
|
||||
|
||||
resMessage = resMessage.Trim();
|
||||
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast(resMessage, TimeSpan.FromSeconds(10));
|
||||
});
|
||||
|
||||
if (string.IsNullOrEmpty(resMessage))
|
||||
{
|
||||
throw new KernelException("chat is empty");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast(ex.Message, TimeSpan.FromSeconds(10));
|
||||
});
|
||||
}
|
||||
|
||||
return resMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
using System.Net.Http.Headers;
|
||||
using Contracts.Services;
|
||||
using ElectronBot.Braincase;
|
||||
using ElectronBot.Braincase.Contracts.Services;
|
||||
using ElectronBot.Braincase.Helpers;
|
||||
using ElectronBot.Braincase.Models;
|
||||
using ElectronBot.Copilot;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.SemanticKernel.ChatCompletion;
|
||||
|
||||
namespace Services;
|
||||
public class ChatGPTChatbotCustomClient : IChatbotClient
|
||||
{
|
||||
public string Name => "ChatGPT-Custom";
|
||||
|
||||
private readonly ILocalSettingsService _localSettingsService;
|
||||
|
||||
private Kernel? _kernel;
|
||||
public ChatGPTChatbotCustomClient(ILocalSettingsService localSettingsService)
|
||||
{
|
||||
_localSettingsService = localSettingsService;
|
||||
}
|
||||
public async Task<string> AskQuestionResultAsync(string message)
|
||||
{
|
||||
var result = await _localSettingsService
|
||||
.ReadSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
throw new Exception("配置为空");
|
||||
}
|
||||
|
||||
|
||||
var hasCustomEndpoint = !string.IsNullOrEmpty(result.OpenAIBaseUrl) && Uri.TryCreate(result.OpenAIBaseUrl, UriKind.Absolute, out var _);
|
||||
var customHttpClient = hasCustomEndpoint
|
||||
? GetProxyClient(result.OpenAIBaseUrl)
|
||||
: default;
|
||||
|
||||
_kernel ??= Kernel.CreateBuilder()
|
||||
.AddOpenAIChatCompletion(result.ChatGPTVersion, result.ChatGPTSessionKey, httpClient: customHttpClient)
|
||||
.Build();
|
||||
|
||||
var chat = _kernel.GetRequiredService<IChatCompletionService>()
|
||||
?? throw new KernelException("not init chat");
|
||||
|
||||
var resMessage = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var history = new ChatHistory();
|
||||
history.AddMessage(AuthorRole.User, message);
|
||||
var response = chat.GetStreamingChatMessageContentsAsync(history);
|
||||
await foreach (var item in response)
|
||||
{
|
||||
resMessage += item;
|
||||
//streamHandler?.Invoke(resMessage);
|
||||
}
|
||||
});
|
||||
|
||||
resMessage = resMessage.Trim();
|
||||
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast(resMessage, TimeSpan.FromSeconds(10));
|
||||
});
|
||||
|
||||
if (string.IsNullOrEmpty(resMessage))
|
||||
{
|
||||
throw new KernelException("chat is empty");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast(ex.Message, TimeSpan.FromSeconds(10));
|
||||
});
|
||||
}
|
||||
|
||||
return resMessage;
|
||||
}
|
||||
|
||||
private static HttpClient GetProxyClient(string baseUrl)
|
||||
{
|
||||
var httpClient = new HttpClient(new ProxyOpenAIHttpClientHandler(baseUrl));
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/event-stream"));
|
||||
return httpClient;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Text.Json;
|
||||
using Contracts.Services;
|
||||
using ElectronBot.Braincase;
|
||||
using ElectronBot.Braincase.Contracts.Services;
|
||||
using ElectronBot.Braincase.Helpers;
|
||||
using ElectronBot.Braincase.Models;
|
||||
|
||||
namespace Services;
|
||||
@@ -70,7 +71,11 @@ public class TuringChatbotClient : IChatbotClient
|
||||
if (retObj.Results != null && retObj.Results.Count > 0)
|
||||
{
|
||||
var retText = retObj.Results[0].Values.Text;
|
||||
|
||||
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast(retText, TimeSpan.FromSeconds(5));
|
||||
});
|
||||
return retText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,20 @@ public class ComboxDataService
|
||||
{
|
||||
|
||||
new ComboxItemModel { DataKey = "Turing", DataValue = "TuringTitle".GetLocalized() },
|
||||
new ComboxItemModel { DataKey = "ChatGPT", DataValue ="ChatGPTTitle".GetLocalized() }
|
||||
new ComboxItemModel { DataKey = "ChatGPT", DataValue ="ChatGPTTitle".GetLocalized() },
|
||||
new ComboxItemModel { DataKey = "ChatGPT-Custom", DataValue ="ChatGPTCustomTitle".GetLocalized() }
|
||||
};
|
||||
}
|
||||
|
||||
public ObservableCollection<ComboxItemModel> GetChatGPTVersionComboxList()
|
||||
{
|
||||
return new ObservableCollection<ComboxItemModel>
|
||||
{
|
||||
|
||||
new ComboxItemModel { DataKey = "gpt-3.5-turbo-0301", DataValue = "gpt-3.5-turbo-0301" },
|
||||
new ComboxItemModel { DataKey = "gpt-4", DataValue ="gpt-4" },
|
||||
new ComboxItemModel { DataKey = "gpt-4-0314", DataValue ="gpt-4-0314" },
|
||||
new ComboxItemModel { DataKey = "gpt-4-0613", DataValue ="gpt-4-0613" }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ElectronBot.Braincase.Models;
|
||||
using ElectronBot.Braincase.Helpers;
|
||||
using ElectronBot.Braincase.Models;
|
||||
using ElectronBot.Braincase.Models.Gps;
|
||||
using ElectronBot.Braincase.Models.Name24;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -20,36 +21,54 @@ namespace ElectronBot.Braincase.Services
|
||||
/// <param name="lat">纬度</param>
|
||||
/// <param name="lon">经度</param>
|
||||
/// <returns>结果封装的类的实例</returns>
|
||||
public async static Task<Weather_Displayed> GetWeatherIdea()
|
||||
public static async Task<Weather_Displayed> GetWeatherIdea()
|
||||
{
|
||||
|
||||
var accessStatus = await Geolocator.RequestAccessAsync();
|
||||
Geolocator geolocator = new Geolocator();
|
||||
if (accessStatus != GeolocationAccessStatus.Allowed) throw new Exception();
|
||||
Geoposition pos = await geolocator.GetGeopositionAsync();
|
||||
double lat = pos.Coordinate.Point.Position.Latitude;
|
||||
double lon = pos.Coordinate.Point.Position.Longitude;
|
||||
string querys = "from=5&lat=" + lat.ToString() + "&lng=" + lon.ToString() + "&need3HourForcast=0&needAlarm=0&needHourData=0&needIndex=1&needMoreDay=1";
|
||||
string url = host + path;
|
||||
string urlLast = url + "?" + querys;
|
||||
Uri uri = new Uri(urlLast);
|
||||
string resultJson = string.Empty;
|
||||
|
||||
var appCode = App.GetService<IOptions<LocalSettingsOptions>>().Value.Hw75AppCode;
|
||||
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Add("Authorization", "APPCODE " + appCode);
|
||||
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
|
||||
resultJson = await httpClient.GetStringAsync(uri);
|
||||
}
|
||||
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<GpsWeatherData>(resultJson);
|
||||
var weatherDisplayed = new Weather_Displayed();
|
||||
var hour24 = await NameGet24Weather.NameGet24WeatherIdea(System.Web.HttpUtility.UrlEncode(data.showapi_res_body.cityInfo.c3, System.Text.Encoding.UTF8));
|
||||
//var hour24 = await NameGet24Weather.NameGet24WeatherIdea(TransCoding.UrlCode(data.showapi_res_body.cityInfo.c3, "utf-8"));
|
||||
OrganizeWeatherData(weatherDisplayed, data, hour24);
|
||||
return weatherDisplayed;
|
||||
try
|
||||
{
|
||||
var accessStatus = await Geolocator.RequestAccessAsync();
|
||||
var geolocator = new Geolocator();
|
||||
if (accessStatus != GeolocationAccessStatus.Allowed)
|
||||
{
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast($"请检查系统设置是否开启系统定位权限。", TimeSpan.FromSeconds(5));
|
||||
});
|
||||
return weatherDisplayed;
|
||||
};
|
||||
var pos = await geolocator.GetGeopositionAsync();
|
||||
var lat = pos.Coordinate.Point.Position.Latitude;
|
||||
var lon = pos.Coordinate.Point.Position.Longitude;
|
||||
var querys = "from=5&lat=" + lat.ToString() + "&lng=" + lon.ToString() + "&need3HourForcast=0&needAlarm=0&needHourData=0&needIndex=1&needMoreDay=1";
|
||||
var url = host + path;
|
||||
var urlLast = url + "?" + querys;
|
||||
var uri = new Uri(urlLast);
|
||||
var resultJson = string.Empty;
|
||||
|
||||
var appCode = App.GetService<IOptions<LocalSettingsOptions>>().Value.Hw75AppCode;
|
||||
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Add("Authorization", "APPCODE " + appCode);
|
||||
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
|
||||
resultJson = await httpClient.GetStringAsync(uri);
|
||||
}
|
||||
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<GpsWeatherData>(resultJson);
|
||||
|
||||
var hour24 = await NameGet24Weather.NameGet24WeatherIdea(System.Web.HttpUtility.UrlEncode(data.showapi_res_body.cityInfo.c3, System.Text.Encoding.UTF8));
|
||||
//var hour24 = await NameGet24Weather.NameGet24WeatherIdea(TransCoding.UrlCode(data.showapi_res_body.cityInfo.c3, "utf-8"));
|
||||
OrganizeWeatherData(weatherDisplayed, data, hour24);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast($"天气获取错误。{ex.Message}", TimeSpan.FromSeconds(5));
|
||||
});
|
||||
}
|
||||
|
||||
return weatherDisplayed;
|
||||
}
|
||||
|
||||
#region 这是数据处理部分
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using ElectronBot.Braincase;
|
||||
using ElectronBot.Braincase.Contracts.Services;
|
||||
using ElectronBot.Braincase.Helpers;
|
||||
using ElectronBot.Braincase.Models;
|
||||
using Models.Hw75.YellowCalendar;
|
||||
|
||||
@@ -21,7 +22,7 @@ public class GetYellowCalendarService
|
||||
|
||||
var yellowCalendarStr = await _localSettingsService.ReadSettingAsync<string>($"{Constants.YellowCalendarKey}-{DateTime.Now.ToShortDateString()}");
|
||||
|
||||
if (noCache == true || string.IsNullOrWhiteSpace(yellowCalendarStr))
|
||||
if (noCache == true || string.IsNullOrWhiteSpace(yellowCalendarStr) || (!string.IsNullOrWhiteSpace(yellowCalendarStr) && !yellowCalendarStr.Contains("successed")))
|
||||
{
|
||||
var httpClient = App.GetService<HttpClient>();
|
||||
|
||||
@@ -36,9 +37,17 @@ public class GetYellowCalendarService
|
||||
{
|
||||
return data.Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast($"请检查聚合数据key的配置", TimeSpan.FromSeconds(5));
|
||||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return new YellowCalendarResult();
|
||||
|
||||
@@ -11,6 +11,6 @@ public class Hw75DynamicCustomViewProvider : IHw75DynamicViewProvider
|
||||
|
||||
public UIElement CreateHw75DynamickView(string viewName)
|
||||
{
|
||||
return new Hw75CustomView();
|
||||
return App.GetService<Hw75CustomView>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ public class Hw75DynamicTodoViewProvider : IHw75DynamicViewProvider
|
||||
|
||||
public UIElement CreateHw75DynamickView(string viewName)
|
||||
{
|
||||
return new TodoView();
|
||||
return App.GetService<TodoView>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ public class Hw75DynamicWeatherViewProvider : IHw75DynamicViewProvider
|
||||
|
||||
public UIElement CreateHw75DynamickView(string viewName)
|
||||
{
|
||||
return new Hw75WeatherView();
|
||||
return App.GetService<Hw75WeatherView>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ public class Hw75DynamicYellowCalendarViewProvider : IHw75DynamicViewProvider
|
||||
|
||||
public UIElement CreateHw75DynamickView(string viewName)
|
||||
{
|
||||
return new Hw75YellowCalendarView();
|
||||
return App.GetService<Hw75YellowCalendarView>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class LocalSettingsService : ILocalSettingsService
|
||||
{
|
||||
if (ApplicationData.Current.LocalSettings.Values.TryGetValue(key, out var obj))
|
||||
{
|
||||
return await Json.ToObjectAsync<T>((string)obj);
|
||||
return await Verdure.ElectronBot.Core.Helpers.Json.ToObjectAsync<T>((string)obj);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -63,7 +63,7 @@ public class LocalSettingsService : ILocalSettingsService
|
||||
|
||||
if (_settings != null && _settings.TryGetValue(key, out var obj))
|
||||
{
|
||||
return await Json.ToObjectAsync<T>((string)obj);
|
||||
return await Verdure.ElectronBot.Core.Helpers.Json.ToObjectAsync<T>((string)obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,13 +74,13 @@ public class LocalSettingsService : ILocalSettingsService
|
||||
{
|
||||
if (RuntimeHelper.IsMSIX)
|
||||
{
|
||||
ApplicationData.Current.LocalSettings.Values[key] = await Json.StringifyAsync(value);
|
||||
ApplicationData.Current.LocalSettings.Values[key] = await Verdure.ElectronBot.Core.Helpers.Json.StringifyAsync(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
await InitializeAsync();
|
||||
|
||||
_settings[key] = await Json.StringifyAsync(value);
|
||||
_settings[key] = await Verdure.ElectronBot.Core.Helpers.Json.StringifyAsync(value);
|
||||
|
||||
await Task.Run(() => _fileService.Save(_applicationDataFolder, _localsettingsFile, _settings));
|
||||
}
|
||||
|
||||
@@ -855,4 +855,10 @@
|
||||
<data name="VerdureBilibili.Content" xml:space="preserve">
|
||||
<value>点击关注我B站获取最新消息</value>
|
||||
</data>
|
||||
<data name="ChatGPTCustomTitle" xml:space="preserve">
|
||||
<value>ChatGPTCustom</value>
|
||||
</data>
|
||||
<data name="ChatGPTVersion.Text" xml:space="preserve">
|
||||
<value>ChatGPT-Model:</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -831,4 +831,10 @@
|
||||
<data name="VerdureBilibili.Content" xml:space="preserve">
|
||||
<value>点击关注我B站获取最新消息</value>
|
||||
</data>
|
||||
<data name="ChatGPTCustomTitle" xml:space="preserve">
|
||||
<value>ChatGPTCustom</value>
|
||||
</data>
|
||||
<data name="ChatGPTVersion.Text" xml:space="preserve">
|
||||
<value>ChatGPT-Model:</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -517,7 +517,13 @@
|
||||
<value>删除</value>
|
||||
</data>
|
||||
<data name="Settings_AboutUpdate.Text" xml:space="preserve">
|
||||
<value>1.7.0 版本更新说明
|
||||
<value>1.7.2 版本更新说明
|
||||
1. 添加语音主动触发按钮,以及添加openai代理域名配置。
|
||||
|
||||
1.7.1 版本更新说明
|
||||
1. 优化提示信息和界面显示。
|
||||
|
||||
1.7.0 版本更新说明
|
||||
1. 升级.Net版本为8.0.
|
||||
2. 添加瀚文键盘模式。
|
||||
|
||||
@@ -861,4 +867,10 @@
|
||||
<data name="VerdureBilibili.Content" xml:space="preserve">
|
||||
<value>点击关注我B站获取最新消息</value>
|
||||
</data>
|
||||
<data name="ChatGPTCustomTitle" xml:space="preserve">
|
||||
<value>ChatGPTCustom</value>
|
||||
</data>
|
||||
<data name="ChatGPTVersion.Text" xml:space="preserve">
|
||||
<value>ChatGPT模型Id:</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -20,7 +20,8 @@
|
||||
<TextBlock
|
||||
Margin="40,20"
|
||||
Foreground="White"
|
||||
Text="{TemplateBinding Content}" />
|
||||
Text="{TemplateBinding Content}"
|
||||
TextWrapping="Wrap" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
@@ -22,7 +22,7 @@ public partial class Hw75CustomViewModel : ObservableRecipient
|
||||
|
||||
private readonly ClockDiagnosticService _diagnosticService;
|
||||
|
||||
private bool isProcessing = false;
|
||||
private const string ViewName = "Hw75CustomView";
|
||||
|
||||
[ObservableProperty] private Visibility _customContentVisibility = Visibility.Visible;
|
||||
|
||||
@@ -30,6 +30,17 @@ public partial class Hw75CustomViewModel : ObservableRecipient
|
||||
|
||||
|
||||
|
||||
public Hw75CustomViewModel(ClockDiagnosticService clockDiagnosticService,
|
||||
ILocalSettingsService localSettingsService)
|
||||
{
|
||||
_diagnosticService = clockDiagnosticService;
|
||||
_localSettingsService = localSettingsService;
|
||||
|
||||
_dispatcherTimer.Interval = new TimeSpan(0, 0, 60);
|
||||
|
||||
_dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
}
|
||||
|
||||
public string TodayWeek
|
||||
{
|
||||
get => _todayWeek;
|
||||
@@ -105,22 +116,15 @@ public partial class Hw75CustomViewModel : ObservableRecipient
|
||||
|
||||
private void DispatcherTimer_Tick(object? sender, object e)
|
||||
{
|
||||
TodayTime = DateTimeOffset.Now.ToString("t");
|
||||
TodayWeek = DateTimeOffset.Now.ToString("ddd");
|
||||
Day = DateTimeOffset.Now.Day.ToString();
|
||||
if (Hw75Helper.Instance.ViewName == ViewName)
|
||||
{
|
||||
TodayTime = DateTimeOffset.Now.ToString("t");
|
||||
TodayWeek = DateTimeOffset.Now.ToString("ddd");
|
||||
Day = DateTimeOffset.Now.Day.ToString();
|
||||
|
||||
Hw75Helper.Instance.InvokeHandler();
|
||||
}
|
||||
Hw75Helper.Instance.InvokeHandler();
|
||||
}
|
||||
|
||||
public Hw75CustomViewModel(ClockDiagnosticService clockDiagnosticService, ILocalSettingsService localSettingsService
|
||||
)
|
||||
{
|
||||
_diagnosticService = clockDiagnosticService;
|
||||
_localSettingsService = localSettingsService;
|
||||
|
||||
_dispatcherTimer.Interval = new TimeSpan(0, 0, 60);
|
||||
|
||||
_dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ public partial class Hw75DynamicViewModel : ObservableRecipient
|
||||
|
||||
private readonly DispatcherTimer _dispatcherTimer = new();
|
||||
|
||||
private const string ViewName = "TodoView";
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<TodoTaskList>? _todoTaskLists;
|
||||
public Hw75DynamicViewModel(IMicrosoftGraphService microsoftGraphService, IdentityService identityService)
|
||||
|
||||
@@ -32,6 +32,8 @@ public partial class Hw75WeatherViewModel : ObservableRecipient
|
||||
[ObservableProperty]
|
||||
private CustomClockTitleConfig? _clockTitleConfig;
|
||||
|
||||
private const string ViewName = "Hw75WeatherView";
|
||||
|
||||
public Hw75WeatherViewModel(ILocalSettingsService localSettingsService)
|
||||
{
|
||||
_localSettingsService = localSettingsService;
|
||||
@@ -43,14 +45,16 @@ public partial class Hw75WeatherViewModel : ObservableRecipient
|
||||
|
||||
private async void DispatcherTimer_Tick(object? sender, object e)
|
||||
{
|
||||
var ret2 = await _localSettingsService.ReadSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey);
|
||||
if (Hw75Helper.Instance.ViewName == ViewName)
|
||||
{
|
||||
var ret2 = await _localSettingsService.ReadSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey);
|
||||
|
||||
ClockTitleConfig = ret2 ?? new CustomClockTitleConfig();
|
||||
ClockTitleConfig = ret2 ?? new CustomClockTitleConfig();
|
||||
|
||||
GpsResult = await GpsGetWeather.GetWeatherIdea();
|
||||
|
||||
Hw75Helper.Instance.InvokeHandler();
|
||||
GpsResult = await GpsGetWeather.GetWeatherIdea();
|
||||
|
||||
Hw75Helper.Instance.InvokeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
@@ -17,6 +17,8 @@ public partial class Hw75YellowCalendarViewModel : ObservableRecipient
|
||||
|
||||
private readonly DispatcherTimer _dispatcherTimer = new ();
|
||||
|
||||
private const string ViewName = "Hw75YellowCalendarView";
|
||||
|
||||
public Hw75YellowCalendarViewModel()
|
||||
{
|
||||
_dispatcherTimer.Interval = new TimeSpan(1, 0, 0);
|
||||
@@ -26,9 +28,12 @@ public partial class Hw75YellowCalendarViewModel : ObservableRecipient
|
||||
|
||||
private async void DispatcherTimer_Tick(object? sender, object e)
|
||||
{
|
||||
YellowCalendarResult = await GetYellowCalendarService.GetYellowCalendarAsync(true);
|
||||
if (Hw75Helper.Instance.ViewName == ViewName)
|
||||
{
|
||||
YellowCalendarResult = await GetYellowCalendarService.GetYellowCalendarAsync(true);
|
||||
|
||||
Hw75Helper.Instance.InvokeHandler();
|
||||
Hw75Helper.Instance.InvokeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
@@ -56,38 +56,39 @@ public partial class Hw75ViewModel : ObservableRecipient, INavigationAware
|
||||
[ObservableProperty]
|
||||
public ObservableCollection<ComboxItemModel> clockComboxModels;
|
||||
|
||||
[ObservableProperty]
|
||||
private CustomClockTitleConfig _clockTitleConfig;
|
||||
|
||||
private readonly IHw75DynamicViewProviderFactory _viewProviderFactory;
|
||||
|
||||
private readonly DispatcherTimer _dispatcherTimer = new();
|
||||
private readonly ILocalSettingsService _localSettingsService;
|
||||
|
||||
public Hw75ViewModel(ComboxDataService comboxDataService, IHw75DynamicViewProviderFactory viewProviderFactory)
|
||||
public Hw75ViewModel(ComboxDataService comboxDataService, IHw75DynamicViewProviderFactory viewProviderFactory, ILocalSettingsService localSettingsService)
|
||||
{
|
||||
ClockComboxModels = comboxDataService.GetHw75ViewComboxList();
|
||||
_viewProviderFactory = viewProviderFactory;
|
||||
_dispatcherTimer.Interval = new TimeSpan(0, 0, 50);
|
||||
|
||||
_dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
_localSettingsService = localSettingsService;
|
||||
}
|
||||
|
||||
private async void DispatcherTimer_Tick(object? sender, object e)
|
||||
{
|
||||
//await Hw75Helper.Instance.SyncDataToDeviceAsync(Element);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 表盘切换方法
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
private void ClockChanged()
|
||||
private async Task ClockChanged()
|
||||
{
|
||||
var clockName = ClockComBoxSelect?.DataKey;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(clockName))
|
||||
{
|
||||
Hw75Helper.Instance.ViewName = clockName;
|
||||
|
||||
var viewProvider = _viewProviderFactory.CreateHw75DynamicViewProvider(clockName);
|
||||
|
||||
Element = viewProvider.CreateHw75DynamickView(clockName);
|
||||
|
||||
ClockTitleConfig.Hw75ViewName = clockName;
|
||||
|
||||
await _localSettingsService.SaveSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey, ClockTitleConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,11 +98,16 @@ public partial class Hw75ViewModel : ObservableRecipient, INavigationAware
|
||||
|
||||
}
|
||||
|
||||
public void OnNavigatedTo(object parameter)
|
||||
public async void OnNavigatedTo(object parameter)
|
||||
{
|
||||
var viewProvider = _viewProviderFactory.CreateHw75DynamicViewProvider("Hw75CustomView");
|
||||
|
||||
Element = viewProvider.CreateHw75DynamickView("Hw75CustomView");
|
||||
var ret2 = await _localSettingsService.ReadSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey);
|
||||
|
||||
ClockTitleConfig = ret2 ?? new CustomClockTitleConfig();
|
||||
|
||||
var viewProvider = _viewProviderFactory.CreateHw75DynamicViewProvider(ClockTitleConfig.Hw75ViewName);
|
||||
|
||||
Element = viewProvider.CreateHw75DynamickView(ClockTitleConfig.Hw75ViewName);
|
||||
|
||||
Hw75Helper.Instance.UpdateDataToDeviceHandler += Instance_UpdateDataToDeviceHandler;
|
||||
|
||||
@@ -133,8 +139,6 @@ public partial class Hw75ViewModel : ObservableRecipient, INavigationAware
|
||||
|
||||
Hw75Helper.Instance.IsConnected = false;
|
||||
}
|
||||
|
||||
_dispatcherTimer.Start();
|
||||
}
|
||||
|
||||
private async void Instance_UpdateDataToDeviceHandler(object? sender, EventArgs e)
|
||||
@@ -147,7 +151,7 @@ public partial class Hw75ViewModel : ObservableRecipient, INavigationAware
|
||||
{
|
||||
Hw75Helper.Instance.Hw75DynamicDevice?.Close();
|
||||
Hw75Helper.Instance.IsConnected = false;
|
||||
Hw75Helper.Instance.ViewName = "Hw75CustomView";
|
||||
Hw75Helper.Instance.UpdateDataToDeviceHandler -= Instance_UpdateDataToDeviceHandler;
|
||||
_dispatcherTimer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ public partial class MainViewModel : ObservableRecipient
|
||||
string resultLabel;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
string _sendText;
|
||||
|
||||
/// <summary>
|
||||
/// 头部舵机
|
||||
|
||||
@@ -7,6 +7,8 @@ using System.Text.Json;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Contracts.Services;
|
||||
using Controls.CompactOverlay;
|
||||
using ElectronBot.Braincase.Contracts.Services;
|
||||
using ElectronBot.Braincase.Contracts.ViewModels;
|
||||
using ElectronBot.Braincase.Helpers;
|
||||
@@ -15,21 +17,17 @@ using ElectronBot.Braincase.Services;
|
||||
using Mediapipe.Net.Solutions;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Microsoft.Graphics.Canvas.UI.Xaml;
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
using Services;
|
||||
using Verdure.ElectronBot.Core.Models;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Graphics;
|
||||
using Windows.Graphics.Imaging;
|
||||
using Windows.Media.Core;
|
||||
using Windows.Media.Playback;
|
||||
using Windows.Media.SpeechRecognition;
|
||||
using Windows.Storage;
|
||||
using Controls.CompactOverlay;
|
||||
using Microsoft.UI.Windowing;
|
||||
|
||||
namespace ElectronBot.Braincase.ViewModels;
|
||||
|
||||
@@ -290,6 +288,228 @@ public partial class MainViewModel : ObservableRecipient, INavigationAware
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task StartChat()
|
||||
{
|
||||
var config = (await _localSettingsService.ReadSettingAsync<CustomClockTitleConfig>
|
||||
(Constants.CustomClockTitleConfigKey)) ?? new CustomClockTitleConfig();
|
||||
|
||||
var textList = config.AnswerText.Split(",").ToList();
|
||||
|
||||
var r = new Random().Next(textList.Count);
|
||||
|
||||
var text = textList[r];
|
||||
|
||||
ToastHelper.SendToast(text, TimeSpan.FromSeconds(4));
|
||||
|
||||
var localSettingsService = App.GetService<ILocalSettingsService>();
|
||||
|
||||
var list = (await _localSettingsService
|
||||
.ReadSettingAsync<List<EmoticonAction>>(Constants.EmojisActionListKey)) ?? new List<EmoticonAction>();
|
||||
|
||||
if (!list.Any(a => a.EmojisType == EmojisType.Default))
|
||||
{
|
||||
var emoticonActions = Constants.EMOJI_ACTION_LIST;
|
||||
await _localSettingsService.SaveSettingAsync(Constants.EmojisActionListKey, emoticonActions.ToList());
|
||||
list = emoticonActions.ToList();
|
||||
}
|
||||
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var emojis = list.First(l => l.NameId == "normal");
|
||||
|
||||
List<ElectronBotAction> actions = new();
|
||||
|
||||
if (emojis.HasAction)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(emojis.EmojisActionPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = string.Empty;
|
||||
|
||||
if (emojis.EmojisType == EmojisType.Default)
|
||||
{
|
||||
path = Package.Current.InstalledLocation.Path + $"\\Assets\\Emoji\\{emojis.EmojisActionPath}";
|
||||
}
|
||||
else
|
||||
{
|
||||
path = emojis.EmojisActionPath;
|
||||
}
|
||||
|
||||
|
||||
var json = await File.ReadAllTextAsync(path);
|
||||
|
||||
|
||||
var actionList = JsonSerializer.Deserialize<List<ElectronBotAction>>(json);
|
||||
|
||||
if (actionList != null && actionList.Count > 0)
|
||||
{
|
||||
actions = actionList;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string? videoPath;
|
||||
|
||||
if (emojis.EmojisType == EmojisType.Default)
|
||||
{
|
||||
videoPath = Package.Current.InstalledLocation.Path + $"\\Assets\\Emoji\\{emojis.NameId}.mp4";
|
||||
}
|
||||
else
|
||||
{
|
||||
videoPath = emojis.EmojisVideoPath;
|
||||
}
|
||||
_ = ElectronBotHelper.Instance.MediaPlayerPlaySoundByTtsAsync(text, true);
|
||||
await App.GetService<IActionExpressionProvider>().PlayActionExpressionAsync(emojis, actions);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
private async Task SendChat()
|
||||
{
|
||||
var config = (await _localSettingsService.ReadSettingAsync<CustomClockTitleConfig>
|
||||
(Constants.CustomClockTitleConfigKey)) ?? new CustomClockTitleConfig();
|
||||
|
||||
var textList = config.AnswerText.Split(",").ToList();
|
||||
|
||||
var r = new Random().Next(textList.Count);
|
||||
|
||||
|
||||
var text = textList[r];
|
||||
|
||||
ToastHelper.SendToast("please wait for a moment", TimeSpan.FromSeconds(4));
|
||||
|
||||
var localSettingsService = App.GetService<ILocalSettingsService>();
|
||||
|
||||
var list = (await _localSettingsService
|
||||
.ReadSettingAsync<List<EmoticonAction>>(Constants.EmojisActionListKey)) ?? new List<EmoticonAction>();
|
||||
|
||||
if (!list.Any(a => a.EmojisType == EmojisType.Default))
|
||||
{
|
||||
var emoticonActions = Constants.EMOJI_ACTION_LIST;
|
||||
await _localSettingsService.SaveSettingAsync(Constants.EmojisActionListKey, emoticonActions.ToList());
|
||||
list = emoticonActions.ToList();
|
||||
}
|
||||
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var emojis = list.First(l => l.NameId == "normal");
|
||||
|
||||
List<ElectronBotAction> actions = new();
|
||||
|
||||
if (emojis.HasAction)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(emojis.EmojisActionPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = string.Empty;
|
||||
|
||||
if (emojis.EmojisType == EmojisType.Default)
|
||||
{
|
||||
path = Package.Current.InstalledLocation.Path + $"\\Assets\\Emoji\\{emojis.EmojisActionPath}";
|
||||
}
|
||||
else
|
||||
{
|
||||
path = emojis.EmojisActionPath;
|
||||
}
|
||||
|
||||
|
||||
var json = await File.ReadAllTextAsync(path);
|
||||
|
||||
|
||||
var actionList = JsonSerializer.Deserialize<List<ElectronBotAction>>(json);
|
||||
|
||||
if (actionList != null && actionList.Count > 0)
|
||||
{
|
||||
actions = actionList;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string? videoPath;
|
||||
|
||||
if (emojis.EmojisType == EmojisType.Default)
|
||||
{
|
||||
videoPath = Package.Current.InstalledLocation.Path + $"\\Assets\\Emoji\\{emojis.NameId}.mp4";
|
||||
}
|
||||
else
|
||||
{
|
||||
videoPath = emojis.EmojisVideoPath;
|
||||
}
|
||||
_ = ElectronBotHelper.Instance.MediaPlayerPlaySoundByTtsAsync("please wait for a moment", false);
|
||||
await App.GetService<IActionExpressionProvider>().PlayActionExpressionAsync(emojis, actions);
|
||||
|
||||
try
|
||||
{
|
||||
//var chatGPTClient = App.GetService<IChatGPTService>();
|
||||
|
||||
//var resultText = await chatGPTClient.AskQuestionResultAsync(args.Result.Text);
|
||||
|
||||
//await ElectronBotHelper.Instance.MediaPlayerPlaySoundByTTSAsync(resultText);
|
||||
|
||||
var chatBotClientFactory = App.GetService<IChatbotClientFactory>();
|
||||
|
||||
var chatBotClientName = (await App.GetService<ILocalSettingsService>()
|
||||
.ReadSettingAsync<ComboxItemModel>(Constants.DefaultChatBotNameKey))?.DataKey;
|
||||
|
||||
if (string.IsNullOrEmpty(chatBotClientName))
|
||||
{
|
||||
throw new Exception("no app key in the config");
|
||||
}
|
||||
|
||||
var chatBotClient = chatBotClientFactory.CreateChatbotClient(chatBotClientName);
|
||||
|
||||
var resultText = await chatBotClient.AskQuestionResultAsync(SendText);
|
||||
|
||||
await ElectronBotHelper.Instance.MediaPlayerPlaySoundByTtsAsync(resultText, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.MainWindow.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
ToastHelper.SendToast(ex.Message, TimeSpan.FromSeconds(3));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
private async Task EndChat()
|
||||
{
|
||||
|
||||
ToastHelper.SendToast("end chat", TimeSpan.FromSeconds(4));
|
||||
|
||||
await ElectronBotHelper.Instance.CloseChatAsync();
|
||||
}
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
private void ElectronEmulation()
|
||||
{
|
||||
@@ -633,7 +853,7 @@ public partial class MainViewModel : ObservableRecipient, INavigationAware
|
||||
|
||||
var clockName = clockComBoxSelect?.DataKey;
|
||||
|
||||
if (clockName != "GooeyFooter"&&clockName!="CustomView")
|
||||
if (clockName != "GooeyFooter" && clockName != "CustomView")
|
||||
{
|
||||
_dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -9,6 +8,7 @@ using ElectronBot.Braincase.Helpers;
|
||||
using ElectronBot.Braincase.Models;
|
||||
using ElectronBot.Braincase.Services;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
using Verdure.ElectronBot.Core.Helpers;
|
||||
@@ -16,7 +16,6 @@ using Verdure.ElectronBot.Core.Models;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Storage;
|
||||
using Windows.System;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace ElectronBot.Braincase.ViewModels;
|
||||
|
||||
@@ -62,6 +61,7 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
_identityService = identityService;
|
||||
_userDataService = userDataService;
|
||||
chatBotComboxModels = comboxDataService.GetChatBotClientComboxList();
|
||||
_chatGPTVersionomboxModels = comboxDataService.GetChatGPTVersionComboxList();
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
var isVisual = toggleSwitch.IsOn;
|
||||
ClockTitleConfig.CustomViewContentIsVisibility = isVisual;
|
||||
}
|
||||
|
||||
|
||||
await _localSettingsService
|
||||
.SaveSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey, _clockTitleConfig);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
|
||||
public async void RangeBase_OnValueChanged(object sender, RangeBaseValueChangedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
await _localSettingsService
|
||||
.SaveSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey, _clockTitleConfig);
|
||||
}
|
||||
@@ -194,6 +194,18 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
[ObservableProperty]
|
||||
public ObservableCollection<ComboxItemModel> chatBotComboxModels;
|
||||
|
||||
/// <summary>
|
||||
/// CHatGPTVersion选中数据
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private ComboxItemModel? _chatGPTVersionSelect;
|
||||
|
||||
/// <summary>
|
||||
/// CHatGPTVersion列表
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<ComboxItemModel>? _chatGPTVersionomboxModels;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 相机列表
|
||||
@@ -291,7 +303,7 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async void RemoveEmojisAvatar()
|
||||
private async Task RemoveEmojisAvatar()
|
||||
{
|
||||
ClockTitleConfig.CustomViewPicturePath = "";
|
||||
await _localSettingsService
|
||||
@@ -310,6 +322,21 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public async Task ChatGPTVersionChangedAsync()
|
||||
{
|
||||
var chatGPTName = ChatGPTVersionSelect?.DataKey;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(chatGPTName))
|
||||
{
|
||||
ClockTitleConfig.ChatGPTVersion = chatGPTName;
|
||||
await _localSettingsService.SaveSettingAsync(Constants.DefaultChatGPTNameKey, chatGPTName);
|
||||
|
||||
await _localSettingsService
|
||||
.SaveSettingAsync(Constants.CustomClockTitleConfigKey, _clockTitleConfig);
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public async Task FeedbackBtnAsync()
|
||||
{
|
||||
@@ -524,6 +551,18 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
ChatBotSelect = chatBotComboxModels.FirstOrDefault(c => c.DataValue == chatBotModel.DataValue);
|
||||
}
|
||||
|
||||
var chatGPTModel = await _localSettingsService
|
||||
.ReadSettingAsync<string>(Constants.DefaultChatGPTNameKey);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(chatGPTModel))
|
||||
{
|
||||
ChatGPTVersionSelect = ChatGPTVersionomboxModels?.FirstOrDefault(c => c.DataKey == chatGPTModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatGPTVersionSelect = ChatGPTVersionomboxModels?.FirstOrDefault(c => c.DataKey == ClockTitleConfig.ChatGPTVersion);
|
||||
}
|
||||
|
||||
_identityService.LoggedIn += OnLoggedIn;
|
||||
_identityService.LoggedOut += OnLoggedOut;
|
||||
_userDataService.UserDataUpdated += OnUserDataUpdated;
|
||||
@@ -577,7 +616,7 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
var config = new ImageCropperConfig
|
||||
{
|
||||
ImageFile = file,
|
||||
AspectRatio = 128d/296d
|
||||
AspectRatio = 128d / 296d
|
||||
};
|
||||
|
||||
var croppedImage = await ImageHelper.CropImage(config);
|
||||
@@ -608,7 +647,7 @@ public partial class SettingsViewModel : ObservableRecipient, INavigationAware
|
||||
[RelayCommand]
|
||||
private async Task RemoveHw75Image()
|
||||
{
|
||||
ClockTitleConfig.CustomHw75ImagePath = "";
|
||||
ClockTitleConfig.CustomHw75ImagePath = "ms-appx:///Assets/Images/Hw75CustomViewDefault.png";
|
||||
await _localSettingsService
|
||||
.SaveSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey, _clockTitleConfig);
|
||||
Hw75ImagePath = "";
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
x:Class="ElectronBot.Braincase.Views.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:clockControl="using:ElectronBot.Braincase.ClockViews"
|
||||
xmlns:control="using:CommunityToolkit.WinUI.UI.Controls"
|
||||
xmlns:controlLocal="using:ElectronBot.Braincase.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="using:Microsoft.Xaml.Interactivity"
|
||||
@@ -132,7 +130,7 @@
|
||||
<StackPanel>
|
||||
<ScrollViewer
|
||||
x:Name="ActionSV"
|
||||
Width="780"
|
||||
Width="600"
|
||||
Height="104"
|
||||
HorizontalScrollBarVisibility="Visible"
|
||||
HorizontalScrollMode="Enabled">
|
||||
@@ -298,6 +296,30 @@
|
||||
<FontIcon FontFamily="/Assets/Font/Segoe Fluent Icons.ttf#Segoe Fluent Icons" Glyph="" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<!--<StackPanel>
|
||||
<Button
|
||||
x:Name="StartChat"
|
||||
x:Uid="StartChat"
|
||||
Height="28"
|
||||
Margin="4"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2"
|
||||
Command="{x:Bind ViewModel.StartChatCommand}"
|
||||
Foreground="{ThemeResource SystemAccentColor}">
|
||||
<FontIcon FontFamily="/Assets/Font/Segoe Fluent Icons.ttf#Segoe Fluent Icons" Glyph="" />
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="EndChat"
|
||||
x:Uid="EndChat"
|
||||
Height="28"
|
||||
Margin="4"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2"
|
||||
Command="{x:Bind ViewModel.EndChatCommand}"
|
||||
Foreground="{ThemeResource SystemAccentColor}">
|
||||
<FontIcon FontFamily="/Assets/Font/Segoe Fluent Icons.ttf#Segoe Fluent Icons" Glyph="" />
|
||||
</Button>
|
||||
</StackPanel>-->
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@@ -321,48 +343,75 @@
|
||||
<RadioButton x:Uid="NeedleModeRb" />
|
||||
</RadioButtons>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Border
|
||||
x:Name="BorderGrid"
|
||||
Width="200"
|
||||
Height="200"
|
||||
Margin="4"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2"
|
||||
Child="{x:Bind ViewModel.Element, Mode=OneWay}"
|
||||
CornerRadius="8" />
|
||||
<StackPanel
|
||||
Margin="4"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="Vertical">
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Border
|
||||
Width="300"
|
||||
Height="200"
|
||||
x:Name="BorderGrid"
|
||||
Width="160"
|
||||
Height="160"
|
||||
Margin="4"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2"
|
||||
CornerRadius="8">
|
||||
<Grid>
|
||||
<Image x:Name="FaceImage" Source="{x:Bind ViewModel.FaceImage.Source, Mode=OneWay}" />
|
||||
<TextBlock
|
||||
x:Uid="CameraPreviewImage"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
FontFamily="/Assets/Font/SmileySans-Oblique.ttf#得意黑"
|
||||
FontSize="18" />
|
||||
</Grid>
|
||||
Child="{x:Bind ViewModel.Element, Mode=OneWay}"
|
||||
CornerRadius="8" />
|
||||
<StackPanel
|
||||
Margin="4"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="Vertical">
|
||||
<Border
|
||||
Width="260"
|
||||
Height="160"
|
||||
VerticalAlignment="Top"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2"
|
||||
CornerRadius="8">
|
||||
<Grid>
|
||||
<Image x:Name="FaceImage" Source="{x:Bind ViewModel.FaceImage.Source, Mode=OneWay}" />
|
||||
<TextBlock
|
||||
x:Uid="CameraPreviewImage"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
FontFamily="/Assets/Font/SmileySans-Oblique.ttf#得意黑"
|
||||
FontSize="18" />
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
<TextBlock
|
||||
x:Name="GestureResult"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="/Assets/Font/SmileySans-Oblique.ttf#得意黑"
|
||||
FontSize="18"
|
||||
Text="{x:Bind ViewModel.ResultLabel, Mode=OneWay}" />
|
||||
</Border>
|
||||
<TextBlock
|
||||
x:Name="GestureResult"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="/Assets/Font/SmileySans-Oblique.ttf#得意黑"
|
||||
FontSize="18"
|
||||
Text="{x:Bind ViewModel.ResultLabel, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBox Width="320" Text="{x:Bind ViewModel.SendText, Mode=TwoWay}" />
|
||||
<Button
|
||||
x:Uid="StartChat"
|
||||
Width="48"
|
||||
Height="36"
|
||||
Margin="2"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2"
|
||||
Command="{x:Bind ViewModel.SendChatCommand}"
|
||||
Foreground="{ThemeResource SystemAccentColor}">
|
||||
<FontIcon FontFamily="/Assets/Font/Segoe Fluent Icons.ttf#Segoe Fluent Icons" Glyph="" />
|
||||
</Button>
|
||||
<Button
|
||||
x:Uid="StartChat"
|
||||
Width="48"
|
||||
Height="36"
|
||||
Margin="2"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2"
|
||||
Command="{x:Bind ViewModel.StartChatCommand}"
|
||||
Foreground="{ThemeResource SystemAccentColor}">
|
||||
<FontIcon FontFamily="/Assets/Font/Segoe Fluent Icons.ttf#Segoe Fluent Icons" Glyph="" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@@ -373,7 +422,7 @@
|
||||
<AdaptiveTrigger MinWindowWidth="1200" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ActionSV.Width" Value="880" />
|
||||
<Setter Target="ActionSV.Width" Value="700" />
|
||||
<Setter Target="ActionEdit.Width" Value="440" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
@@ -382,7 +431,7 @@
|
||||
<AdaptiveTrigger MinWindowWidth="0" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ActionSV.Width" Value="780" />
|
||||
<Setter Target="ActionSV.Width" Value="700" />
|
||||
<Setter Target="ActionEdit.Width" Value="340" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
@@ -445,6 +445,36 @@
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="8" Orientation="Horizontal">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="180" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
x:Uid="ChatGPTVersion"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center" />
|
||||
<Grid Grid.Column="1">
|
||||
<ComboBox
|
||||
x:Uid="ChangeGPTVersionCB"
|
||||
Width="160"
|
||||
Margin="0,0,8,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
DisplayMemberPath="DataValue"
|
||||
ItemsSource="{x:Bind ViewModel.ChatGPTVersionomboxModels}"
|
||||
SelectedItem="{x:Bind ViewModel.ChatGPTVersionSelect, Mode=TwoWay}">
|
||||
<i:Interaction.Behaviors>
|
||||
<ic:EventTriggerBehavior EventName="SelectionChanged">
|
||||
<ic:InvokeCommandAction Command="{x:Bind ViewModel.ChatGPTVersionChangedCommand}" />
|
||||
</ic:EventTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="8" Orientation="Horizontal">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -520,6 +550,32 @@
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<StackPanel Margin="8" Orientation="Horizontal">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="180" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Text="OpenAI BaseUrl:" />
|
||||
<Grid Grid.Column="1">
|
||||
<TextBox
|
||||
Width="360"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{x:Bind ViewModel.ClockTitleConfig.OpenAIBaseUrl, Mode=TwoWay, UpdateSourceTrigger=LostFocus}">
|
||||
<i:Interaction.Behaviors>
|
||||
<ic:EventTriggerBehavior EventName="LostFocus">
|
||||
<ic:InvokeCommandAction Command="{x:Bind ViewModel.TextChangedCommand}" />
|
||||
</ic:EventTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="8" Orientation="Horizontal">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.1" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231219000" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronBot.Copilot;
|
||||
|
||||
public class ProxyOpenAIHttpClientHandler : HttpClientHandler
|
||||
{
|
||||
private readonly string _proxyUrl;
|
||||
|
||||
public ProxyOpenAIHttpClientHandler(string proxyUrl)
|
||||
=> _proxyUrl = proxyUrl.TrimEnd('/');
|
||||
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.RequestUri != null && request.RequestUri.Host.Equals("api.openai.com", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var path = request.RequestUri.PathAndQuery.TrimStart('/');
|
||||
request.RequestUri = new Uri($"{_proxyUrl}/{path}");
|
||||
}
|
||||
|
||||
return base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
//using Microsoft.SemanticKernel;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Net.Http;
|
||||
//using System.Net.Http.Headers;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace ElectronBot.Copilot
|
||||
//{
|
||||
// public class VerdureChatKernel
|
||||
// {
|
||||
// private readonly ILocalSettingsService _localSettingsService;
|
||||
// public VerdureChatKernel()
|
||||
// {
|
||||
|
||||
// }
|
||||
// private Microsoft.SemanticKernel.Kernel _kernel;
|
||||
|
||||
// /// <summary>
|
||||
// /// 语义内核.
|
||||
// /// </summary>
|
||||
// public Kernel Kernel
|
||||
// {
|
||||
// get => _kernel;
|
||||
// set
|
||||
// {
|
||||
// _kernel = value;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private static async Task LoadOpenAIConfiguration(VerdureChatKernel kernel, string modelName = default)
|
||||
// {
|
||||
// var accessKey = GlobalSettings.TryGet<string>(SettingNames.OpenAIAccessKey);
|
||||
// var org = GlobalSettings.TryGet<string>(SettingNames.OpenAIOrganization);
|
||||
// var customEndpoint = GlobalSettings.TryGet<string>(SettingNames.OpenAICustomEndpoint);
|
||||
// var model = string.IsNullOrEmpty(modelName)
|
||||
// ? GlobalSettings.TryGet<string>(SettingNames.DefaultOpenAIChatModelName)
|
||||
// : modelName;
|
||||
|
||||
// if (string.IsNullOrEmpty(accessKey)
|
||||
// || string.IsNullOrEmpty(model))
|
||||
// {
|
||||
// throw new Models.App.Args.KernelException(KernelExceptionType.InvalidConfiguration);
|
||||
// }
|
||||
|
||||
// var result = await App.Get<>_localSettingsService
|
||||
// .ReadSettingAsync<CustomClockTitleConfig>(Constants.CustomClockTitleConfigKey);
|
||||
|
||||
// if (result == null)
|
||||
// {
|
||||
// throw new Exception("配置为空");
|
||||
// }
|
||||
|
||||
// _chatGptClient ??= new ChatGPTClient(result.ChatGPTSessionKey, "gpt-3.5-turbo");
|
||||
|
||||
// _chatGptClient.Settings.OpenAIAPIBaseUri = result.OpenAIBaseUrl;
|
||||
|
||||
|
||||
|
||||
// var hasCustomEndpoint = !string.IsNullOrEmpty(customEndpoint) && Uri.TryCreate(customEndpoint, UriKind.Absolute, out var _);
|
||||
// var customHttpClient = hasCustomEndpoint
|
||||
// ? GetProxyClient(customEndpoint)
|
||||
// : default;
|
||||
|
||||
// kernel.Kernel = Kernel
|
||||
// .CreateBuilder()
|
||||
// .AddOpenAIChatCompletion(model, accessKey, org, httpClient: customHttpClient)
|
||||
// .Build();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// private static HttpClient GetProxyClient(string baseUrl)
|
||||
// {
|
||||
// var httpClient = new HttpClient(new ProxyOpenAIHttpClientHandler(baseUrl));
|
||||
// httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/event-stream"));
|
||||
// return httpClient;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -6,8 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.ML" Version="2.0.1" />
|
||||
<PackageReference Include="Microsoft.ML.LightGbm" Version="2.0.1" />
|
||||
<PackageReference Include="Microsoft.ML" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.ML.LightGbm" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="MLModel1">
|
||||
<None Include="MLModel1.consumption.cs">
|
||||
|
||||
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
@@ -9,8 +9,6 @@ namespace HelloWordKeyboard.DotNet;
|
||||
|
||||
public class Hw75DynamicDevice : IHw75DynamicDevice
|
||||
{
|
||||
private const string Path = "\\\\?\\hid#vid_1d50&pid_615e&mi_01#8&a8a6dc9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
|
||||
|
||||
private const int RePortCount = 63;
|
||||
|
||||
private const int PayloadSize = RePortCount - 1;
|
||||
@@ -148,9 +146,14 @@ public class Hw75DynamicDevice : IHw75DynamicDevice
|
||||
{
|
||||
if (deviceInfo.UsagePage == ZmkxUasage)
|
||||
{
|
||||
return new Device(deviceInfo.Path);
|
||||
_device = new Device(deviceInfo.Path);
|
||||
var version = GetVersion();
|
||||
if (version.Features.HasEink && version.Features.Eink == true)
|
||||
{
|
||||
return new Device(deviceInfo.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Exception("瀚文设备未连接");
|
||||
throw new Exception("瀚文拓展设备未连接");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="Google.Protobuf" Version="3.25.0" />
|
||||
<PackageReference Include="Mediapipe.Net.Framework.Protobuf" Version="1.0.0-alpha2" />
|
||||
<PackageReference Include="Mediapipe.Net.Framework.Protobuf" Version="0.9.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||