Merge pull request #13 from ikechan8370/v2

up
This commit is contained in:
ycxom 2025-02-27 20:21:23 +08:00 committed by GitHub
commit 58e2985a28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 3 deletions

View file

@ -15,6 +15,8 @@
> 由于相关领域发展快速迭代较多本文档有部分过时内容不确定的问题可以开discussion或加群问群里的大佬们哦
>
> 插件大幅重构中v2分支仅做最低程度维护。
### 推荐的相关文档和参考资料
本README

View file

@ -788,7 +788,7 @@ export class chatgpt extends plugin {
let thinking = chatMessage.thinking_text
for (let processor of postProcessors) {
let output = await processor.processInner({
text: response, thinking
text: response, thinking_text: thinking
})
response = output.text
thinking = output.thinking_text

View file

@ -151,7 +151,7 @@ export class ClaudeAPIClient extends BaseClient {
let messages = history.map(h => { return { role: h.role, content: h.content } })
body = Object.assign(body, {
model: opt.model || this.model || 'claude-3-opus-20240229',
max_tokens: opt.max_tokens || 1024,
max_tokens: opt.max_tokens || 4096,
messages,
stream: false
})

View file

@ -259,7 +259,29 @@ class Core {
stream: false,
parentMessageId: conversation.parentMessageId,
conversationId: conversation.conversationId,
system: opt.system.claude
system: opt.system.claude,
max_tokens: Config.apiMaxToken
}
if (opt.settings.enableGroupContext && e.isGroup) {
let chats = await getChatHistoryGroup(e, Config.groupContextLength)
const namePlaceholder = '[name]'
const defaultBotName = 'GeminiPro'
const groupContextTip = Config.groupContextTip
let botName = e.isGroup ? (e.group.pickMember(getUin(e)).card || e.group.pickMember(getUin(e)).nickname) : e.bot.nickname
option.system = option.system.replaceAll(namePlaceholder, botName || defaultBotName) +
((opt.settings.enableGroupContext && e.group_id) ? groupContextTip : '')
option.system += 'Attention, you are currently chatting in a qq group, then one who asks you now is' + `${e.sender.card || e.sender.nickname}(${e.sender.user_id}).`
option.system += `the group name is ${e.group.name || e.group_name}, group id is ${e.group_id}.`
option.system += `Your nickname is ${botName} in the group,`
if (chats) {
option.system += 'There is the conversation history in the group, you must chat according to the conversation history context"'
option.system += chats
.map(chat => {
let sender = chat.sender || {}
return `${sender.card || sender.nickname}】(qq${sender.user_id}, ${roleMap[sender.role] || 'normal user'}${sender.area ? 'from ' + sender.area + ', ' : ''} ${sender.age} years old, 群头衔:${sender.title}, gender: ${sender.sex}, time${formatDate(new Date(chat.time * 1000))}, messageId: ${chat.message_id}) 说:${chat.raw_message}`
})
.join('\n')
}
}
let img = await getImg(e)
if (img && img.length > 0) {