mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +00:00
fix: gemini强制调用tool;real at
This commit is contained in:
parent
c13f4dec05
commit
f4e4f1bebb
2 changed files with 20 additions and 4 deletions
|
|
@ -80,7 +80,8 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient {
|
|||
* temperature: number?,
|
||||
* topP: number?,
|
||||
* tokK: number?,
|
||||
* replyPureTextCallback: Function
|
||||
* replyPureTextCallback: Function,
|
||||
* toolMode: 'AUTO' | 'ANY' | 'NONE'
|
||||
* }} opt
|
||||
* @returns {Promise<{conversationId: string?, parentMessageId: string, text: string, id: string}>}
|
||||
*/
|
||||
|
|
@ -173,9 +174,17 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient {
|
|||
}
|
||||
]
|
||||
// ANY要笑死人的效果
|
||||
let mode = opt.toolMode || 'AUTO'
|
||||
let lastFuncName = opt.functionResponse?.name
|
||||
const mustSendNextTurn = [
|
||||
'searchImage', 'searchMusic', 'searchVideo'
|
||||
]
|
||||
if (lastFuncName && mustSendNextTurn.includes(lastFuncName)) {
|
||||
mode = 'ANY'
|
||||
}
|
||||
body.tool_config = {
|
||||
function_calling_config: {
|
||||
mode: 'AUTO'
|
||||
mode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -215,6 +224,7 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient {
|
|||
const text = responseContent.parts.find(i => i.text)?.text
|
||||
if (text) {
|
||||
// send reply first
|
||||
logger.info('send message: ' + text)
|
||||
opt.replyPureTextCallback && await opt.replyPureTextCallback(text)
|
||||
}
|
||||
// Gemini有时候只回复一个空的functionCall,无语死了
|
||||
|
|
|
|||
|
|
@ -470,13 +470,19 @@ export async function convertFaces (msg, handleAt = false, e) {
|
|||
let groupCardQQMap = {}
|
||||
if (handleAt) {
|
||||
try {
|
||||
groupMembers = e.bot.gml
|
||||
groupMembers = e.bot.gml.get(e.group_id)
|
||||
} catch (err) {
|
||||
console.error(`Failed to get group members: ${err}`)
|
||||
}
|
||||
if (groupMembers) {
|
||||
for (let key of groupMembers.keys()) {
|
||||
groupCardQQMap[groupMembers.get(key).card || groupMembers.get(key).nickname] = groupMembers.get(key).user_id
|
||||
let userInfo = groupMembers.get(key)
|
||||
if (userInfo.card) {
|
||||
groupCardQQMap[userInfo.card] = userInfo.user_id
|
||||
}
|
||||
if (userInfo.nickname) {
|
||||
groupCardQQMap[userInfo.nickname] = userInfo.user_id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue