Skip to content

refactor: 使用Google官方SDK重构gemini_source #1228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0b76609
refactor: 初步完成gemini_source的重写
Raven95676 Apr 10, 2025
4244d37
chore: 格式化代码,禁用gemini source debug输出
Raven95676 Apr 10, 2025
cc6cd96
fix: 修复潜在的空消息
Raven95676 Apr 11, 2025
0dc5b4c
perf: 增加对RECITATION完成原因的处理,提取内容处理逻辑到独立方法
Raven95676 Apr 11, 2025
2ca95ea
fix: 在设置新key后重新初始化Gemini客户端
Raven95676 Apr 11, 2025
e8ffebc
fix: 修复消息处理流程中可能出现的空消息
Raven95676 Apr 11, 2025
1b3963e
fix: 更新类型提示,简化代码并修复潜在的空值问题。
Raven95676 Apr 11, 2025
3bbb477
Merge branch 'master' into gemini
Raven95676 Apr 11, 2025
c5e8bc7
fix: 修复模型生成内容的重试机制。
Raven95676 Apr 11, 2025
54035d1
Merge branch 'gemini' of https://github.com/Raven95676/AstrBot-Rdev i…
Raven95676 Apr 11, 2025
b493a80
fix: 处理更多多模态不支持错误
Raven95676 Apr 11, 2025
bd24cf3
feat: 初步完成原生流式请求逻辑
Raven95676 Apr 11, 2025
44dbe47
refactor: 拆分方法以提高代码可读性
Raven95676 Apr 11, 2025
3860634
fix: 修复了多模态输出支持判断问题并对只输出图片的情况进行处理。
Raven95676 Apr 12, 2025
9c29df4
fix: 更新流式输出逻辑,禁用图片模态并添加日志警告。
Raven95676 Apr 12, 2025
739f090
feat: 为Gemini原生代码执行器提供有限支持
Raven95676 Apr 13, 2025
310ed76
fix: 仅在确实包含图片模态时降级
Raven95676 Apr 13, 2025
fe95506
perf: 添加日志过滤器以抑制非文本部分警告信息
Raven95676 Apr 13, 2025
6986c8d
fix: clean code,处理Gemini流式输出最后一部分概率性为None的情况
Raven95676 Apr 13, 2025
a769fd7
chore: add google-genai dependency to project
Soulter Apr 15, 2025
43ee943
🐛 fix: 多轮函数调用的报错
Soulter Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions astrbot/core/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@
"model": "gemini-2.0-flash-exp",
},
"gm_resp_image_modal": False,
"gm_native_coderunner": False,
"gm_safety_settings": {
"harassment": "BLOCK_MEDIUM_AND_ABOVE",
"hate_speech": "BLOCK_MEDIUM_AND_ABOVE",
Expand Down Expand Up @@ -704,6 +705,12 @@
"type": "bool",
"hint": "启用后,将支持返回图片内容。需要模型支持,否则会报错。具体支持模型请查看 Google Gemini 官方网站。温馨提示,如果您需要生成图片,请关闭 `启用群员识别` 配置获得更好的效果。",
},
"gm_native_coderunner": {
"description": "启用原生代码执行器",
"type": "bool",
"hint": "启用后所有函数工具将全部失效",
"obvious_hint": True,
},
"gm_safety_settings": {
"description": "安全过滤器",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion astrbot/core/provider/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async def assemble_context(self) -> Dict:
if self.image_urls:
user_content = {
"role": "user",
"content": [{"type": "text", "text": self.prompt}],
"content": [{"type": "text", "text": self.prompt if self.prompt else "[图片]"}],
}
for image_url in self.image_urls:
if image_url.startswith("http"):
Expand Down
Loading