修复 API调用400失败 Fix #81

This commit is contained in:
ZouJin 2023-08-22 19:07:51 +10:00
parent 37c693f705
commit 27bb96e345

View File

@ -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")