Skip to content

Feature: Add provider_type field for ProviderMetadata and improve provider availability test #2054

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 10 commits into from
Jul 13, 2025

Conversation

RC-CHN
Copy link
Contributor

@RC-CHN RC-CHN commented Jul 8, 2025

Motivation

使得调用方可以根据 Provider 的大分类(如 CHAT_COMPLETION, TTS 等)进行筛选和识别,增强了元数据的可用性。

Modifications

在 ProviderMeta 中添加 provider_type 字段,并在 AbstractProvider 的 meta 方法中从全局注册表获取该值。

Check

  • 😊 我的 Commit Message 符合良好的规范
  • 👀 我的更改经过良好的测试
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。
  • 😮 我的更改没有引入恶意代码

好的,这是翻译成中文的 pull request 总结:

Sourcery 总结

ProviderMeta schema 中添加一个新的 provider_type 字段,并在 AbstractProvider.meta 方法中基于全局 provider 注册表填充该字段。

新特性:

  • 通过 ProviderMeta 中的新 provider_type 字段暴露 provider 类别

增强:

  • AbstractProvider.meta 中使用全局 provider 注册表填充 provider_type,以便按 provider 类别进行过滤
Original summary in English

Summary by Sourcery

Add a new provider_type field to the ProviderMeta schema and populate it in the AbstractProvider.meta method based on the global provider registry.

New Features:

  • Expose provider category via a new provider_type field in ProviderMeta

Enhancements:

  • Populate provider_type in AbstractProvider.meta using the global provider registry for filtering by provider category

Copy link
Contributor

sourcery-ai bot commented Jul 8, 2025

## 审查者指南

向 ProviderMeta 添加了一个新的 provider_type 属性,并更新了 AbstractProvider.meta 以从全局 provider 注册表中查找并填充该字段。

### 文件级别更改

| 变更 | 详情 | 文件 |
| ------ | ------- | ----- |
| 扩展 ProviderMeta 以包含 provider_type | <ul><li>向 ProviderMeta 类定义添加了 provider_type 注解</li></ul> | `astrbot/core/provider/provider.py` |
| 在 AbstractProvider.meta 中填充 provider_type | <ul><li>从注册表中导入了 provider_cls_map</li><li>从 provider_config 派生了 provider_type_name</li><li>在获取的元数据上查找了 provider_type</li><li>将 provider_type 传递到返回的 ProviderMeta 中</li></ul> | `astrbot/core/provider/provider.py` |

---

<details>
<summary>提示和命令</summary>

#### 与 Sourcery 互动

- **触发新的审查:** 在 pull request 上评论 `@sourcery-ai review`- **继续讨论:** 直接回复 Sourcery 的审查评论。
- **从审查评论生成 GitHub issue:** 通过回复审查评论,要求 Sourcery 从该评论创建一个 issue。您也可以回复带有 `@sourcery-ai issue` 的审查评论来从中创建一个 issue。
- **生成 pull request 标题:** 在 pull request 标题中的任何位置写入 `@sourcery-ai` 以随时生成标题。您也可以在 pull request 上评论 `@sourcery-ai title` 以随时(重新)生成标题。
- **生成 pull request 摘要:** 在 pull request 正文中的任何位置写入 `@sourcery-ai summary` 以随时在您想要的位置生成 PR 摘要。您也可以在 pull request 上评论 `@sourcery-ai summary` 以随时(重新)生成摘要。
- **生成审查者指南:** 在 pull request 上评论 `@sourcery-ai guide` 以随时(重新)生成审查者指南。
- **解决所有 Sourcery 评论:** 在 pull request 上评论 `@sourcery-ai resolve` 以解决所有 Sourcery 评论。如果您已经处理了所有评论并且不想再看到它们,这将非常有用。
- **驳回所有 Sourcery 审查:** 在 pull request 上评论 `@sourcery-ai dismiss` 以驳回所有现有的 Sourcery 审查。如果您想从新的审查开始,这将特别有用 - 不要忘记评论 `@sourcery-ai review` 以触发新的审查!

#### 自定义您的体验

访问您的 [仪表板](https://app.sourcery.ai) 以:
- 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
- 更改审查语言。
- 添加、删除或编辑自定义审查说明。
- 调整其他审查设置。

#### 获取帮助

- [联系我们的支持团队](mailto:support@sourcery.ai) 提出问题或反馈。
- 访问我们的 [文档](https://docs.sourcery.ai) 获取详细的指南和信息。
- 通过在 [X/Twitter](https://x.com/SourceryAI)[LinkedIn](https://www.linkedin.com/company/sourcery-ai/)[GitHub](https://github.com/sourcery-ai) 上关注我们,与 Sourcery 团队保持联系。

</details>
Original review guide in English

Reviewer's Guide

Adds a new provider_type attribute to ProviderMeta and updates AbstractProvider.meta to lookup and populate that field from the global provider registry.

File-Level Changes

Change Details Files
Extend ProviderMeta to include provider_type
  • Added provider_type annotation to ProviderMeta class definition
astrbot/core/provider/provider.py
Populate provider_type in AbstractProvider.meta
  • Imported provider_cls_map from registry
  • Derived provider_type_name from provider_config
  • Looked up provider_type on the fetched metadata
  • Passed provider_type into the returned ProviderMeta
astrbot/core/provider/provider.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RC-CHN - 我已经查看了你的更改,它们看起来很棒!


Sourcery 对开源是免费的 - 如果你喜欢我们的评论,请考虑分享它们✨
帮助我更有用!请点击每个评论上的👍或👎,我将使用反馈来改进你的评论。
Original comment in English

Hey @RC-CHN - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Soulter Soulter changed the title feat:meta方法增加provider_type字段 Feature: Add provider_type field for ProviderMetadata and improve provider availabiliby test Jul 13, 2025
@Soulter Soulter linked an issue Jul 13, 2025 that may be closed by this pull request
2 tasks
@Soulter Soulter merged commit ae06d94 into AstrBotDevs:master Jul 13, 2025
3 checks passed
@Soulter Soulter changed the title Feature: Add provider_type field for ProviderMetadata and improve provider availabiliby test Feature: Add provider_type field for ProviderMetadata and improve provider availability test Jul 13, 2025
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.

[Bug]使用embedding时出现代码层级报错
2 participants