Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions VPet.Plugin.ChatVPet/CVPTTalkAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ private void VoiceRecognize()
//{
// return int.Max(7, (int)Math.Sqrt(like / 16) - 2);
//}
public override void Responded(string content)
public override void Responded(string content) // 处理响应内容
{
if (string.IsNullOrEmpty(content))
{
return;
}
DisplayThink();
DisplayThink(); // 显示思考动画
if (Plugin.CGPTClient == null)
{
DisplayThinkToSayRnd("请先前往设置中设置 GPT API".Translate());
MessageBox.Show("请先前往设置中设置 GPT API".Translate());
return;
}
Dispatcher.Invoke(() => this.IsEnabled = false);
Expand All @@ -104,7 +104,7 @@ public override void Responded(string content)
{
if (pr.IsError)
{
Plugin.MW.Main.LabelDisplayShow("VCP报错: ".Translate() + pr.Reply);
MessageBox.Show("VCP报错: ".Translate() + pr.Reply); // 显示错误消息弹窗Label
}
else if (!string.IsNullOrWhiteSpace(pr.Reply))
{
Expand All @@ -130,7 +130,7 @@ public override void Responded(string content)
{
string? model = Plugin.CGPTClient.Completions["vpet"].model?.ToLower();
if (string.IsNullOrWhiteSpace(model) || !model.Contains("gpt-4") || !model.Contains("o1") || !model.Contains("pro") ||
!model.Contains("plus") || !model.Contains("max"))//确保提交质量
!model.Contains("plus") || !model.Contains("max"))//确保提交质量
return;

string[]? msg = Plugin.VPetChatProcess.Dialogues.LastOrDefault()?.ToMessages(Plugin.VPetChatProcess.Localization);
Expand Down Expand Up @@ -158,7 +158,9 @@ public override void Responded(string content)
{
str = "请检查API token设置".Translate();
}
DisplayThinkToSayRnd("API调用失败".Translate() + $",{str}\n{e}");//, GraphCore.Helper.SayType.Serious);
DisplayThinkToSayRndAutoNoForce("API调用失败".Translate() + $",{str}\n{e}"); //, GraphCore.Helper.SayType.Serious);
MessageBox.Show("API调用失败".Translate() + $",{str}\n{e}"); // 显示错误消息弹窗
Dispatcher.Invoke(() => this.IsEnabled = true); // 恢复按钮可用状态
}
}
bool istalksuccess = false;
Expand Down
21 changes: 14 additions & 7 deletions VPet.Plugin.ChatVPet/CVP_Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public partial class CVPPlugin

public string? ToolStopWork(Dictionary<string, string> args)
{
MW.Main.WorkTimer.Stop(reason: FinishWorkInfo.StopReason.MenualStop);
MW.Dispatcher.Invoke(() => MW.Main.WorkTimer.Stop(reason: FinishWorkInfo.StopReason.MenualStop));
return null;
}
public string? ToolDance(Dictionary<string, string> args)
Expand Down Expand Up @@ -87,14 +87,21 @@ public partial class CVPPlugin
}
public string? ToolSleep(Dictionary<string, string> args)
{
MW.Main.WorkTimer.Stop(reason: FinishWorkInfo.StopReason.MenualStop);
var m = MW.Main;
if (m.State == Main.WorkingState.Nomal)
m.DisplaySleep(true);
else if (m.State != Main.WorkingState.Sleep)
MW.Dispatcher.Invoke(() =>
{
m.WorkTimer.Stop(() => m.DisplaySleep(true), WorkTimer.FinishWorkInfo.StopReason.MenualStop);
}
if (m.State == Main.WorkingState.Nomal)
{
// 正常状态直接睡觉
m.DisplaySleep(true);
}
else if (m.State != Main.WorkingState.Sleep)
{
// 如果正在工作,先停止工作再睡觉
m.WorkTimer.Stop(() => m.DisplaySleep(true), WorkTimer.FinishWorkInfo.StopReason.MenualStop);
}
// 如果已经是睡眠状态,什么都不做
});
return null;
}
public string? ToolWakeup(Dictionary<string, string> args)
Expand Down
2 changes: 2 additions & 0 deletions VPet.Plugin.ChatVPet/VPet.Plugin.ChatVPet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<selfContained>true</selfContained>
</PropertyGroup>

<ItemGroup>
Expand Down