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.....)", }, }, ],