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

Abierto
#10,874 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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 以帮助实现该功能。
Lenguaje dominante
Python
Estrellas
46.4k
Forks
3.4k
Merge medio
1 d 11 h
PR fusionados (30 d)
120

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AstrBotDevs/AstrBot

Todos los issues de AstrBotDevs/AstrBot

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.