Browse Source

Merge pull request #1816 from xywhnh/master

修复gemini 插件的两个问题
master
Saboteur7 GitHub 9 months ago
parent
commit
2c4b8a44dc
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      bot/gemini/google_gemini_bot.py

+ 3
- 0
bot/gemini/google_gemini_bot.py View File

@@ -44,6 +44,7 @@ class GoogleGeminiBot(Bot):
except Exception as e: except Exception as e:
logger.error("[Gemini] fetch reply error, may contain unsafe content") logger.error("[Gemini] fetch reply error, may contain unsafe content")
logger.error(e) logger.error(e)
return Reply(ReplyType.ERROR, "invoke [Gemini] api failed!")


def _convert_to_gemini_messages(self, messages: list): def _convert_to_gemini_messages(self, messages: list):
res = [] res = []
@@ -63,6 +64,8 @@ class GoogleGeminiBot(Bot):
def _filter_messages(self, messages: list): def _filter_messages(self, messages: list):
res = [] res = []
turn = "user" turn = "user"
if not messages:
return res
for i in range(len(messages) - 1, -1, -1): for i in range(len(messages) - 1, -1, -1):
message = messages[i] message = messages[i]
if message.get("role") != turn: if message.get("role") != turn:


Loading…
Cancel
Save