[Feature] Gemini 原生搜索:返回引用来源,并在配置提示中说明 Google 的展示条款

Đang mở
#10,874 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend, documentation

Hướng nghiên cứu

Start with astrbot/core/provider/sources/gemini_source.py, especially _process_content_parts, and the gm_native_search configuration hint in astrbot/core/config/default.py; read the linked Gemini terms and issue #9728 for the existing source field and card. Decide how to display both grounding sources and Search Suggestions across chat platforms, including the stated audience restriction, then update the implementation, configuration hint, and documentation to match that decision.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement
功能描述

开启 gm_native_search 后,适配器会在请求里加上 google_search 工具(gemini_source.py#L252-L253),但解析响应时只读取 candidate.content.parts(_process_content_parts),candidate.grounding_metadata 被整个丢弃,仓库中没有任何读取它的代码。结果是:

  • 回复里没有来源链接(grounding_chunks[].web 的 uri、title),用户无法核查答案;
  • Search Suggestions(search_entry_point.rendered_content)也被丢弃。

Gemini API 附加条款对 Grounding with Google Search 的要求:

You will only use Grounding with Google Search in an application that is owned and operated by you and will only display the Grounded Results with the associated Search Suggestion(s) to the end user who submitted the prompt.

Unless permitted by Google in writing, you: (1) will not modify, or intersperse any other content with, the Grounded Results or Search Suggestions; ...

AstrBot 常见的用法是在 QQ 群等聊天平台里回复:群里所有人都能看到回复,平台也渲染不了 Search Suggestions 的 HTML/CSS。按现在的实现,在群聊里开启这个开关无法满足上述条款,但配置提示只写了"启用后所有函数工具将全部失效,免费次数限制请查阅官方文档"(default.py#L2623),没有提到这一点。

建议

  1. 加个开关决定是否解析 grounding_metadata.grounding_chunks,把来源(标题和原始链接)附在回复里。#9728 为 xAI 新增了 LLMResponse.web_search_sources 和来源卡片,如果合并 Gemini 可以复用同一字段。
  2. 在 gm_native_search 的配置提示和文档里写明条款限制:结果只能展示给提问者本人,并须同时展示 Search Suggestions;群聊场景得说明。
  3. 需要决定的是:在渲染不了 HTML 的平台上如何处理 Search Suggestions,例如只在 WebUI 渲染,或在群聊中禁用原生搜索。
使用场景
  • 用 Gemini 原生搜索回答新闻、版本号等时效性问题时,用户需要知道来源才能判断答案是否可靠。
  • 部署者在开启前需要知道:在群聊使用原生搜索与可能与 Google 条款冲突。
检查清单
  • 我已在 Issue 列表中搜索过相关功能,确认该功能想法从未被提出过。
  • 我建议的功能与 AstrBot 本体相关,而非在建议某一插件的功能。
  • 我已阅读并同意本项目的贡献者行为准则。
  • (可选)我愿意提交 PR 以帮助实现该功能。
Ngôn ngữ chính
Python
Star
46.4k
Fork
3.4k
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
120

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AstrBotDevs/AstrBot

Tất cả issue của AstrBotDevs/AstrBot

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.