mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
🎈 perf: 更换gpt客户端为浏览器客户端免魔法&免sk
This commit is contained in:
parent
d8aa6264c5
commit
e92d15978d
@ -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);
|
||||
|
@ -6,4 +6,4 @@ translateAppId: '' # 百度翻译APP ID
|
||||
translateSecret: '' # 百度翻译密匙
|
||||
|
||||
biliSessData: '' # 哔哩哔哩的SESSDATA
|
||||
openaiApiKey: '' # OpenAI的API Key, sk...
|
||||
openaiAccessToken: '' # 通过获取:https://chat.openai.com/api/auth/session
|
||||
|
@ -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.....)",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user