修改suno伪造生成策略,支持更多模型调用

This commit is contained in:
zyc404 2024-05-08 15:32:49 +08:00
parent 123e5304a7
commit d111d2625e
7 changed files with 86 additions and 30 deletions

View file

@ -5,6 +5,7 @@ import { Config } from '../utils/config.js'
import { v4 as uuid } from 'uuid'
import AzureTTS from '../utils/tts/microsoft-azure.js'
import VoiceVoxTTS from '../utils/tts/voicevox.js'
import BingSunoClient from '../utils/BingSuno.js'
import {
completeJSON,
formatDate,
@ -20,7 +21,8 @@ import {
makeForwardMsg,
randomString,
render,
renderUrl
renderUrl,
extractMarkdownJson
} from '../utils/common.js'
import fetch from 'node-fetch'
@ -838,6 +840,31 @@ export class chatgpt extends plugin {
await redis.set(key, JSON.stringify(previousConversation), Config.conversationPreserveTime > 0 ? { EX: Config.conversationPreserveTime } : {})
}
}
// 处理suno生成
if ((use === 'bing' || use === 'xh') && Config.enableChatSuno) {
const sunoList = extractMarkdownJson(chatMessage.text)
for (let suno of sunoList) {
if (suno.json.option == 'Suno') {
chatMessage.text = chatMessage.text.replace(suno.markdown, `歌曲 《${suno.json.title}`)
logger.info(`开始生成歌曲${suno.json.tags}`)
let client = new BingSunoClient() // 此处使用了bing的suno客户端后续和本地suno合并
redis.set(`CHATGPT:SUNO:${e.sender.user_id}`, 'c', { EX: 30 }).then(() => {
try {
if (Config.SunoModel == 'local') {
// 调用本地Suno配置进行歌曲生成
client.getLocalSuno(suno.json, e)
} else if (Config.SunoModel == 'api') {
// 调用第三方Suno配置进行歌曲生成
client.getApiSuno(suno.json, e)
}
} catch (err) {
redis.del(`CHATGPT:SUNO:${e.sender.user_id}`)
this.reply('歌曲生成失败:' + err)
}
})
}
}
}
let response = chatMessage?.text?.replace('\n\n\n', '\n')
let mood = 'blandness'
if (!response) {