Skip to content

feat: 多平台支持与 GROK_MODEL 环境变量#14

Open
summerKK wants to merge 2 commits intoGuDaStudio:mainfrom
summerKK:feat/multi-platform-support
Open

feat: 多平台支持与 GROK_MODEL 环境变量#14
summerKK wants to merge 2 commits intoGuDaStudio:mainfrom
summerKK:feat/multi-platform-support

Conversation

@summerKK
Copy link

Summary

  • 新增多平台自动检测:根据 GROK_API_URL 自动识别 xAI 官方 / OpenRouter / 通用 OpenAI 兼容平台
  • 新增 GROK_MODEL 环境变量支持,OpenRouter 用户可通过 :online 后缀启用原生实时搜索
  • 新增 GROK_PROVIDER 环境变量,支持手动指定平台类型
  • 新增 OpenRouter annotations 解析,搜索结果自动附带来源引用(Sources)
  • 针对 online 模型使用精简的 system prompt(online_search_prompt / online_fetch_prompt),避免冗余指令干扰原生搜索能力

Changes

src/grok_search/config.py

  • grok_model 属性新增环境变量 GROK_MODEL 优先级(环境变量 > 配置文件 > 默认值)
  • 新增 provider_type 属性:自动检测或手动指定平台类型(xai / openrouter / generic
  • 新增 is_online_model 属性:检测模型是否带 :online 后缀
  • 配置信息输出中增加 GROK_PROVIDERGROK_ONLINE_SEARCH 字段

src/grok_search/providers/grok.py

  • search()fetch() 方法根据 is_online_model 动态选择 system prompt
  • _parse_streaming_response() 新增 annotations 收集逻辑
  • 新增 _append_citations() 静态方法,将 url_citation 类型的 annotations 格式化为 Markdown 引用列表

src/grok_search/utils.py

  • 新增 online_search_prompt:面向有原生搜索能力的模型,输出纯 JSON 数组
  • 新增 online_fetch_prompt:面向有原生抓取能力的模型,返回结构化 Markdown

文档

  • README.md / docs/README_EN.md:新增多平台支持章节、环境变量说明表、OpenRouter 配置示例、FAQ

summerKK and others added 2 commits February 10, 2026 22:58
- 新增 GROK_MODEL 环境变量支持(优先级:env > config.json > 默认值)
- 自动检测 API 平台类型(xAI / OpenRouter / Generic)
- OpenRouter :online 后缀启用原生实时搜索
- 解析 annotations 提取真实来源引用
- online 模式使用精简 system prompt

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- 新增多平台支持章节(OpenRouter / xAI / Generic)
- 更新安装示例包含 GROK_MODEL 配置
- 新增环境变量说明表格
- 新增 OpenRouter :online 使用指南
- 新增常见问题(搜索不准确、平台支持、:online 后缀)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@summerKK
Copy link
Author

解决 openrouter 的 grok 模型不会调用 web search tool 问题 #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant