mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +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 { getVideoInfo, getDynamic } from "../utils/biliInfo.js";
|
||||||
import { getBiliGptInputText } from "../utils/biliSummary.js";
|
import { getBiliGptInputText } from "../utils/biliSummary.js";
|
||||||
import { getBodianAudio, getBodianMv, getBodianMusicInfo } from "../utils/bodian.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";
|
import { av2BV } from "../utils/bilibili-bv-av-convert.js";
|
||||||
|
|
||||||
export class tools extends plugin {
|
export class tools extends plugin {
|
||||||
@ -91,16 +91,13 @@ export class tools extends plugin {
|
|||||||
// 加载哔哩哔哩配置
|
// 加载哔哩哔哩配置
|
||||||
this.biliSessData = this.toolsConfig.biliSessData;
|
this.biliSessData = this.toolsConfig.biliSessData;
|
||||||
// 加载gpt配置
|
// 加载gpt配置
|
||||||
this.openaiApiKey = this.toolsConfig.openaiApiKey;
|
this.openaiAccessToken = this.toolsConfig.openaiAccessToken;
|
||||||
// 加载gpt客户端
|
// 加载gpt客户端
|
||||||
this.chatGptClient = new ChatGPTClient(this.openaiApiKey, {
|
this.chatGptClient = new ChatGPTBrowserClient({
|
||||||
modelOptions: {
|
reverseProxyUrl: "https://bypass.churchless.tech/api/conversation",
|
||||||
model: "gpt-3.5-turbo",
|
accessToken: this.openaiAccessToken,
|
||||||
temperature: 0,
|
model: "gpt-3.5-turbo",
|
||||||
},
|
})
|
||||||
proxy: this.myProxy,
|
|
||||||
debug: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 翻译插件
|
// 翻译插件
|
||||||
@ -367,7 +364,7 @@ export class tools extends plugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 如果有ck 并且 有openai的key
|
// 如果有ck 并且 有openai的key
|
||||||
if (this.biliSessData && this.openaiApiKey) {
|
if (this.biliSessData && this.openaiAccessToken) {
|
||||||
try {
|
try {
|
||||||
const prompt = await getBiliGptInputText(videoInfo, this.biliSessData);
|
const prompt = await getBiliGptInputText(videoInfo, this.biliSessData);
|
||||||
const response = await this.chatGptClient.sendMessage(prompt);
|
const response = await this.chatGptClient.sendMessage(prompt);
|
||||||
|
@ -6,4 +6,4 @@ translateAppId: '' # 百度翻译APP ID
|
|||||||
translateSecret: '' # 百度翻译密匙
|
translateSecret: '' # 百度翻译密匙
|
||||||
|
|
||||||
biliSessData: '' # 哔哩哔哩的SESSDATA
|
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",
|
field: "tools.openaiAccessToken",
|
||||||
label: "OpenAI的API-KEY",
|
label: "OpenAI的AccessToken",
|
||||||
bottomHelpMessage:
|
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",
|
component: "Input",
|
||||||
required: false,
|
required: false,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: "请输入OpenAI的API-KEY(sk.....)",
|
placeholder: "请输入OpenAI的AccessToken(ey.....)",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user