From 27bb96e345c47cc5d34b79c909aa3442b549d7b4 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Tue, 22 Aug 2023 19:07:51 +1000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20API=E8=B0=83=E7=94=A8400?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=20Fix=20#81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml.cs b/VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml.cs index 28c0adb..cce7fd8 100644 --- a/VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml.cs @@ -1,5 +1,6 @@ using LinePutScript.Localization.WPF; using System; +using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -50,6 +51,18 @@ namespace VPet_Simulator.Windows Dispatcher.Invoke(() => this.IsEnabled = false); try { + if (mw.CGPTClient.Completions.TryGetValue("vpet", out var vpetapi)) + { + var last = vpetapi.messages.LastOrDefault(); + if (last != null) + { + if(last.role == ChatGPT.API.Framework.Message.RoleType.user) + { + vpetapi.messages.Remove(last); + } + } + } + var resp = mw.CGPTClient.Ask("vpet", content); var reply = resp.GetMessageContent(); if (resp.choices[0].finish_reason == "length")