Skip to content

feat: add Requesty provider template - #93

Closed
Thibaultjaigu wants to merge 2 commits into
Radiant303:mainfrom
Thibaultjaigu:add-requesty-provider
Closed

Thibaultjaigu wants to merge 2 commits into
Radiant303:mainfrom
Thibaultjaigu:add-requesty-provider

Conversation

@Thibaultjaigu

Copy link
Copy Markdown

Adds Requesty as a built-in provider template, next to OpenRouter. Requesty is an OpenAI compatible LLM router, so it uses the existing openaiCompatible protocol and needs no client changes.

概述 / Summary

Adds a "Requesty" entry to the add provider dialog. Selecting it pre-fills the name, base URL https://router.requesty.ai/v1, API path /chat/completions and two example models, the same way the OpenRouter template works.

改动点 / Changes

  • spring_note/lib/core/models/provider_config.dart: Requesty added to templateNames after OpenRouter, plus a matching branch in ProviderConfig.template (example models openai/gpt-4.1-mini and anthropic/claude-sonnet-4-5, both marked text and image like the OpenRouter ones).
  • docs/guide/providers.md, docs/en/guide/providers.md: Requesty added to the template list.
  • spring_note/test/ai_client_service_test.dart: small test for the new template.

截图或录屏 / Screenshots or Recordings

The only UI change is one more chip in the existing template grid of the add provider dialog.

验证方式 / Verification

  • flutter analyze on the touched files: no issues. Full flutter analyze reports the same 22 info level issues as upstream main.
  • flutter test: ai_client_service_test.dart and settings_page_test.dart pass. Full suite: 297 passed, 6 failed; the same 6 tests (local_data_service, memory_services, startup_report_generation) also fail on a clean upstream main on my machine (macOS).
  • cargo test in spring_note/rust: not needed, no Rust changes.
  • flutter build windows --release: not run (macOS machine).
  • 手动测试 / Manual test: with a Requesty key, the template's provider config passed through AiClientService.testProviderConnectionStream returned "Streaming connection succeeded" with model openai/gpt-4o-mini. The Rust ai::chat path returned a normal reply, and fetch_provider_models listed the models from /v1/models.

How to try it: Settings > Providers > Add provider > Requesty, paste a key from https://app.requesty.ai/api-keys, then use a model id such as openai/gpt-4o-mini. Docs: https://docs.requesty.ai. An EU endpoint is also available at https://router.eu.requesty.ai/v1 by editing the Base URL.


检查清单 / Checklist

  • 😊 本 PR 范围清晰,不包含无关改动。/ This PR has a clear scope and does not include unrelated changes.
  • 👀 我已测试受影响功能,或说明了为什么不适用测试。/ I have tested the affected feature or explained why testing is not applicable.
  • 🖼️ 如果修改了 UI,我已附上截图或录屏。/ If this changes UI, I have attached screenshots or recordings.
  • 🤓 如果修改了依赖,我已更新 pubspec.yaml、pubspec.lock、Cargo.toml 或 Cargo.lock 等对应文件。/ If this changes dependencies, I have updated the correct files such as pubspec.yaml, pubspec.lock, Cargo.toml, or Cargo.lock. (No dependency changes.)
  • 🔐 本 PR 没有暴露 API Key、Token、本地路径或用户隐私数据。/ This PR does not expose API keys, tokens, local paths, or private user data.
  • 😮 本 PR 没有引入恶意代码。/ This PR does not introduce malicious code.

破坏性变更 / Breaking changes

  • 这不是破坏性变更。/ This is NOT a breaking change.
  • 这是破坏性变更,我已在下方说明影响。/ This is a breaking change and I have explained the impact below.

Disclosure: I work at Requesty. Happy to adjust anything to match project conventions.

Add Requesty (OpenAI compatible router at https://router.requesty.ai/v1) as a built-in provider template next to OpenRouter, list it in the provider docs, and cover the template with a unit test.
@github-actions

Copy link
Copy Markdown
Contributor

AI 审查结果

审查结论

本次 PR 变更内容直观:在代码中新增 Requesty 供应商模板、同步中英文文档,并添加一个基本测试。整体实现简单,无重大安全问题。主要风险集中在模板默认模型 ID 的准确性(可能不符合 Requesty 实际 API 要求)以及测试覆盖不足。

问题列表

1. 严重程度:中 — 模板模型 ID 可能不适用于 Requesty

  • 位置:spring_note/lib/core/models/provider_config.dart 第 194-210 行(新增的 Requesty 模板分支)
  • 原因:模板中模型 ID 使用了带前缀格式,如 openai/gpt-4.1-mini、anthropic/claude-sonnet-4-5。Requesty 是一个聚合路由器,它的 API 可能要求模型 ID 为 gpt-4.1-mini 或 claude-sonnet-4-5 这样的纯模型名(类似 OpenAI 兼容接口),也可能支持前缀。但当前模板直接采用类似 OpenRouter 风格的格式,而未验证实际接口要求。若 Requesty 不支持前缀,用户使用模板创建 Provider 后调用将失败,导致功能不可用。
  • 建议:核对 Requesty 官方 API 文档,确认模型 ID 格式。若 Router 要求的是纯模型名,应改为 gpt-4.1-mini 和 claude-sonnet-4-5;若确实需要前缀,则保留并补充注释说明。同时建议在代码中增加对 baseUrl 和 apiPath 的 URL 组合合理性检查(如是否重复 /v1)。

2. 严重程度:低 — 新增测试覆盖不足

  • 位置:spring_note/test/ai_client_service_test.dart 第 136-146 行(Requesty 模板测试)
  • 原因:测试仅验证了 name、protocol、baseUrl、apiPath 和第一个 model 的 modelId,未检查 enabled 是否为 true、apiKey 为空、models 长度及第二个模型。如果后续有人误改模板(如将 enabled 设为 false 或改错模型数量),当前测试无法捕获回归。
  • 建议:补充断言如 expect(requesty.enabled, isTrue)、expect(requesty.apiKey, isEmpty)、expect(requesty.models.length, 2),并检查第二个模型的 modelId。

3. 低:文档与代码顺序已同步,无需处理

  • 位置:docs/en/guide/providers.md 和 docs/guide/providers.md
  • 说明:中文和英文文档均新增了 Requesty 且位置与代码中 templateNames 列表一致(OpenRouter 之后)。无问题。

剩余风险

  • 未对 Requesty 模板进行真实 API 联调,模型 ID 格式是否正确只能通过文档验证。
  • 模板列表继续通过硬编码维护,新增供应商时需同步修改多个文件,未来可考虑通过配置化方式降低维护成本,但属可接受范围。
  • 未检查 templateNames 列表中是否会出现拼写或大小写不一致(当前 'Requesty' 与 normalized 逻辑匹配,风险低)。

@Thibaultjaigu

Copy link
Copy Markdown
Author

Following up on the automated review:

  1. Model id format: Requesty expects vendor/model ids, so openai/gpt-4.1-mini and anthropic/claude-sonnet-4-5 are the right format. I verified both live against https://router.requesty.ai/v1/chat/completions just now: both return 200 and both are listed with vision support in /v1/models. The bare gpt-4.1-mini is rejected with "Invalid model ID", so the prefix is required. The base URL plus apiPath compose to the same /v1/chat/completions shape as the OpenRouter template, so there is no duplicated /v1; a generic URL sanity check would touch every template, happy to do that separately if you want it.
  2. Test coverage: ac02378 now also asserts enabled, the empty apiKey, and both model ids.
  3. Docs: nothing to change.

中文摘要:Requesty 使用 vendor/model 格式,两个模型 ID 均已实测可用;测试已补充完整断言。

@Radiant303

Copy link
Copy Markdown
Owner

We will not consider adding new providers for the time being.

@Radiant303 Radiant303 closed this Sep 25, 2026
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.

2 participants