mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: remove long translation result forward
This commit is contained in:
parent
f1b950ce58
commit
bf75c002c0
2 changed files with 13 additions and 4 deletions
|
|
@ -170,10 +170,10 @@ ${translateLangLabels}
|
|||
await this.reply(err.message, e.isGroup)
|
||||
return false
|
||||
}
|
||||
const totalLength = Array.isArray(result)
|
||||
? result.reduce((acc, cur) => acc + cur.length, 0)
|
||||
: result.length
|
||||
if (totalLength > 300 || multiText) {
|
||||
// const totalLength = Array.isArray(result)
|
||||
// ? result.reduce((acc, cur) => acc + cur.length, 0)
|
||||
// : result.length
|
||||
if (multiText) {
|
||||
// 多条翻译结果
|
||||
if (Array.isArray(result)) {
|
||||
result = await makeForwardMsg(e, result, '翻译结果')
|
||||
|
|
|
|||
|
|
@ -122,6 +122,15 @@ export async function translate (msg, to = 'auto', from = 'auto', ai = Config.tr
|
|||
// if ai is not in the list, throw error
|
||||
if (!['openai', 'gemini', 'xh', 'qwen'].includes(ai)) throw new Error('ai来源错误')
|
||||
let system = `You will be provided with a sentence in the language with language code [${from}], and your task is to translate it into [${lang}]. Just print the result without any other words.`
|
||||
if (Array.isArray(msg)) {
|
||||
let result = []
|
||||
for (let i = 0; i < msg.length; i++) {
|
||||
let item = msg[i]
|
||||
let res = await translate(item, to, from, ai)
|
||||
result.push(res)
|
||||
}
|
||||
return result
|
||||
}
|
||||
switch (ai) {
|
||||
case 'openai': {
|
||||
let api = new ChatGPTAPI({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue