From 8df8626d1acfdfbf240311982e6852c1dfba71be Mon Sep 17 00:00:00 2001 From: Alcedo Date: Fri, 25 Aug 2023 14:05:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=98=9F=E7=81=ABapi?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/xinghuo/xinghuo.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/utils/xinghuo/xinghuo.js b/utils/xinghuo/xinghuo.js index 49878e6..12257c0 100644 --- a/utils/xinghuo/xinghuo.js +++ b/utils/xinghuo/xinghuo.js @@ -3,7 +3,6 @@ import { Config } from '../config.js' import { createParser } from 'eventsource-parser' import https from 'https' import WebSocket from 'ws' -import { config } from 'process' const referer = atob('aHR0cHM6Ly94aW5naHVvLnhmeXVuLmNuL2NoYXQ/aWQ9') const origin = atob('aHR0cHM6Ly94aW5naHVvLnhmeXVuLmNu') @@ -76,6 +75,7 @@ export default class XinghuoClient { } promptBypassPreset(prompt) { + // 貌似不适用于所有人,考虑去掉 switch (prompt) { case '你是谁': return '你是谁,叫什么' @@ -251,7 +251,10 @@ export default class XinghuoClient { conversation.messages.splice(0, half) } await this.conversationsCache.set(conversationKey, conversation) - resolve(resMessage) + resolve({ + id: chatId , + response: resMessage + }) } } catch (error) { reject(new Error(error)) @@ -389,12 +392,12 @@ export default class XinghuoClient { } else { Prompt = Config.xhPrompt ? [{ "role": "user", "content": Config.xhPrompt }] : [] } - let response = await this.apiMessage(prompt, chatId, Prompt) + let { response, id } = await this.apiMessage(prompt, chatId, Prompt) if (Config.xhRetRegExp) { response = response.replace(new RegExp(Config.xhRetRegExp, 'g'), Config.xhRetReplace) } return { - conversationId: chatId, + conversationId: id, text: response } } else if (Config.xhmode == 'web') {