From e92d15978dc5aa598414ffd695d104187b2da02d Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Fri, 7 Apr 2023 11:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E6=9B=B4=E6=8D=A2gpt?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E4=B8=BA=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E5=85=8D=E9=AD=94=E6=B3=95&?= =?UTF-8?q?=E5=85=8Dsk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 19 ++++++++----------- config/tools.yaml | 2 +- guoba.support.js | 8 ++++---- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 6192f5e..0814a03 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -17,7 +17,7 @@ import * as xBogus from "../utils/x-bogus.cjs"; import { getVideoInfo, getDynamic } from "../utils/biliInfo.js"; import { getBiliGptInputText } from "../utils/biliSummary.js"; import { getBodianAudio, getBodianMv, getBodianMusicInfo } from "../utils/bodian.js"; -import { ChatGPTClient } from "@waylaidwanderer/chatgpt-api"; +import { ChatGPTBrowserClient } from "@waylaidwanderer/chatgpt-api"; import { av2BV } from "../utils/bilibili-bv-av-convert.js"; export class tools extends plugin { @@ -91,16 +91,13 @@ export class tools extends plugin { // 加载哔哩哔哩配置 this.biliSessData = this.toolsConfig.biliSessData; // 加载gpt配置 - this.openaiApiKey = this.toolsConfig.openaiApiKey; + this.openaiAccessToken = this.toolsConfig.openaiAccessToken; // 加载gpt客户端 - this.chatGptClient = new ChatGPTClient(this.openaiApiKey, { - modelOptions: { - model: "gpt-3.5-turbo", - temperature: 0, - }, - proxy: this.myProxy, - debug: false, - }); + this.chatGptClient = new ChatGPTBrowserClient({ + reverseProxyUrl: "https://bypass.churchless.tech/api/conversation", + accessToken: this.openaiAccessToken, + model: "gpt-3.5-turbo", + }) } // 翻译插件 @@ -367,7 +364,7 @@ export class tools extends plugin { }); // 如果有ck 并且 有openai的key - if (this.biliSessData && this.openaiApiKey) { + if (this.biliSessData && this.openaiAccessToken) { try { const prompt = await getBiliGptInputText(videoInfo, this.biliSessData); const response = await this.chatGptClient.sendMessage(prompt); diff --git a/config/tools.yaml b/config/tools.yaml index 5681ceb..6d891f7 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -6,4 +6,4 @@ translateAppId: '' # 百度翻译APP ID translateSecret: '' # 百度翻译密匙 biliSessData: '' # 哔哩哔哩的SESSDATA -openaiApiKey: '' # OpenAI的API Key, sk... +openaiAccessToken: '' # 通过获取:https://chat.openai.com/api/auth/session diff --git a/guoba.support.js b/guoba.support.js index 643e695..bb39c3b 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -87,14 +87,14 @@ export function supportGuoba() { }, }, { - field: "tools.openaiApiKey", - label: "OpenAI的API-KEY", + field: "tools.openaiAccessToken", + label: "OpenAI的AccessToken", bottomHelpMessage: - "如何获取参考文章:https://chatgpt.cn.obiscr.com/blog/posts/2023/How-to-get-api-key/", + "ey....,先登录:https://chat.openai.com/,再复制里面的accessToken:https://chat.openai.com/api/auth/session", component: "Input", required: false, componentProps: { - placeholder: "请输入OpenAI的API-KEY(sk.....)", + placeholder: "请输入OpenAI的AccessToken(ey.....)", }, }, ],