优化歌曲消息匹配,适配更多模型支持生成歌曲

This commit is contained in:
zyc404 2024-05-09 22:09:51 +08:00
parent 554f6a69f3
commit 7288e2b845
6 changed files with 402 additions and 37 deletions

View file

@ -832,13 +832,25 @@ export class chatgpt extends plugin {
}
}
// 处理suno生成
if ((use === 'bing' || use === 'xh' || use === 'gemini') && Config.enableChatSuno) {
if (Config.enableChatSuno) {
let client = new BingSunoClient() // 此处使用了bing的suno客户端后续和本地suno合并
const sunoList = extractMarkdownJson(chatMessage.text)
if (sunoList.length == 0) {
const lyrics = client.extractLyrics(chatMessage.text)
if (lyrics !== '') {
sunoList.push(
{
json: { option: 'Suno', tags: client.generateRandomStyle(), title: `${e.sender.nickname}之歌`, lyrics: lyrics },
markdown: null,
origin: lyrics
}
)
}
}
for (let suno of sunoList) {
if (suno.json.option == 'Suno') {
chatMessage.text = chatMessage.text.replace(suno.markdown, `歌曲 《${suno.json.title}`)
chatMessage.text = chatMessage.text.replace(suno.origin, `歌曲 《${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') {