mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-04 06:38:05 +08:00
chore(deps): httpx 全面迁移到 httpx2,SOCKS5 改用原生代理,升级 LLM SDK 大版本
- 依赖 httpx[socks] 换为 httpx2[socks]>=2.15,移除 httpx-socks / python-socks 及其 mypy 覆盖 - backend/src、ab_sdk、e2e 与单元测试统一使用 httpx2(异常类与 httpx 不通用) - request_url 与 LLM 客户端工厂合并为 proxy_url(),SOCKS5 走 httpx2 原生代理(主机名由代理解析) - 保留 #1104 过期连接池替换:httpcore2 2.15.1 的 start_tls 失败路径仍会泄漏隧道 - 日志同时压低 httpx2 与 httpx(google-genai、mcp 仍依赖旧 httpx) - openai 3.35.1 / anthropic 1.15.0 / google-genai 2.31.0;结构化解析改用 chat.completions.parse - ab_sdk 升到 0.6.0,客户端类型改为 httpx2.AsyncClient,同步插件文档
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
1. 安装 SDK 与命令行。轮子随每个 4.0 beta / 正式版发布在 [GitHub Releases](https://github.com/EstrellaXD/Auto_Bangumi/releases) 的附件中(文件名 `autobangumi_sdk-<SDK 版本>-py3-none-any.whl`),不发布到 PyPI。详见 [获取 SDK](/dev/plugins/sdk)。
|
||||
|
||||
```bash
|
||||
uv tool install ./autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
uv tool install ./autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
2. 生成骨架并测试。骨架的 `pyproject.toml` 依赖 `autobangumi-sdk`,而 PyPI 上没有这个包,所以先用 `uv add` 让它指向下载的轮子:
|
||||
@@ -19,7 +19,7 @@
|
||||
```bash
|
||||
ab-plugin new my-rename --kind rename # 也可选 notifier、search
|
||||
cd my-rename
|
||||
uv add ../autobangumi_sdk-0.5.0-py3-none-any.whl # 换成轮子的实际路径
|
||||
uv add ../autobangumi_sdk-0.6.0-py3-none-any.whl # 换成轮子的实际路径
|
||||
uv run pytest # 骨架自带契约测试
|
||||
```
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
`ab-plugin` 随 `autobangumi-sdk` 轮子安装,只依赖 `ab_sdk`,不需要安装 AutoBangumi。
|
||||
|
||||
```bash
|
||||
uv tool install ./autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
# 或在项目里:uv add ./autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
uv tool install ./autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
# 或在项目里:uv add ./autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
轮子在 4.0 beta / 正式版的 GitHub Release 附件中,不发布到 PyPI,见 [获取 SDK](/dev/plugins/sdk)。契约测试需要 pytest:`new` 生成的 `pyproject.toml` 已在 `dev` 依赖组里带上 pytest;自己建的项目用 `uv add --dev pytest`(或安装 `autobangumi-sdk[test]`)。
|
||||
@@ -65,7 +65,7 @@ ab-plugin dev [path] [--config-dir config]
|
||||
```bash
|
||||
ab-plugin new my-notify --kind notifier
|
||||
cd my-notify
|
||||
uv add ../autobangumi_sdk-0.5.0-py3-none-any.whl # 只需一次
|
||||
uv add ../autobangumi_sdk-0.6.0-py3-none-any.whl # 只需一次
|
||||
uv run pytest # 契约测试
|
||||
ab-plugin dev . --config-dir /path/to/autobangumi/config # 链接并开启热重载,重启 AB 一次
|
||||
# 改代码 → AB 自动重载 → 在 WebUI 里验证
|
||||
|
||||
@@ -27,6 +27,7 @@ class MyPlugin(Plugin):
|
||||
## 要点
|
||||
|
||||
- `ProviderInfo` 驱动前端表单和提供商列表:`auth_kind` 为 `api_key`、`oauth` 或 `device_code`。
|
||||
- 适配器通过 `AdapterContext` 拿到模型名、密钥、`base_url`、超时和代理感知的 httpx 客户端工厂,不读全局配置。
|
||||
- 适配器通过 `AdapterContext` 拿到模型名、密钥、`base_url`、超时和代理感知的 httpx2 客户端工厂,不读全局配置。
|
||||
- 工厂返回 `httpx2.AsyncClient`(SDK 0.6 起,此前为 `httpx`);捕获网络异常时用 `httpx2.HTTPError` 等,`httpx` 的异常类捕获不到它抛出的错误。
|
||||
- 订阅类提供商(`oauth` / `device_code`)实现认证流程钩子(`AuthChallenge`、`TokenSet`)。凭据失效且刷新失败时抛出 `AuthExpiredError`,AB 会熔断该提供商并发 `llm_auth_failure` 事件。
|
||||
- 现有的 `plugin.json` 格式 LLM 插件(`llm-plugins` 发布)继续可用;新插件使用 `plugin.toml` 与本扩展点。
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
| `autobangumi_sdk-<SDK 版本>-py3-none-any.whl` | `ab_sdk` 包与 `ab-plugin` 命令行 |
|
||||
| `autobangumi-plugin-skill-<AB 版本>.zip` | 给 AI 编码助手使用的插件开发 skill |
|
||||
|
||||
轮子文件名里是 SDK 版本(`ab_sdk.SDK_VERSION`,如 `0.5.0`),不是 AB 的版本号。请从目标 AB 版本的 Release 下载轮子,两者的 SDK 版本一致。插件清单里的 `sdk` 范围(如 `">=0.5,<1"`)必须包含这个版本。
|
||||
轮子文件名里是 SDK 版本(`ab_sdk.SDK_VERSION`,如 `0.6.0`),不是 AB 的版本号。请从目标 AB 版本的 Release 下载轮子,两者的 SDK 版本一致。插件清单里的 `sdk` 范围(如 `">=0.5,<1"`)必须包含这个版本。
|
||||
|
||||
## 安装轮子
|
||||
|
||||
轮子要求 Python 3.13 或更高,依赖 `pydantic`、`httpx` 与 `packaging`,不需要安装 AutoBangumi。
|
||||
轮子要求 Python 3.13 或更高,依赖 `pydantic`、`httpx2` 与 `packaging`,不需要安装 AutoBangumi。
|
||||
|
||||
只用命令行时,装成全局工具:
|
||||
|
||||
```bash
|
||||
uv tool install ./autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
uv tool install ./autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
ab-plugin --help
|
||||
```
|
||||
|
||||
@@ -24,7 +24,7 @@ ab-plugin --help
|
||||
|
||||
```bash
|
||||
cd my-plugin
|
||||
uv add ../autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
uv add ../autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
uv run pytest
|
||||
```
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ A plugin is a Python package, with optional frontend components. It runs inside
|
||||
1. Install the SDK and the command line. The wheel is an attachment of each 4.0 beta and stable release on [GitHub Releases](https://github.com/EstrellaXD/Auto_Bangumi/releases). The file name is `autobangumi_sdk-<SDK version>-py3-none-any.whl`. The wheel is not on PyPI. Refer to [Get the SDK](/en/dev/plugins/sdk).
|
||||
|
||||
```bash
|
||||
uv tool install ./autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
uv tool install ./autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
2. Create a skeleton and run its tests. The `pyproject.toml` of the skeleton needs `autobangumi-sdk`. This package is not on PyPI. Thus, first use `uv add` to point the dependency to the wheel that you downloaded:
|
||||
@@ -19,7 +19,7 @@ A plugin is a Python package, with optional frontend components. It runs inside
|
||||
```bash
|
||||
ab-plugin new my-rename --kind rename # or notifier, search
|
||||
cd my-rename
|
||||
uv add ../autobangumi_sdk-0.5.0-py3-none-any.whl # use the real path of the wheel
|
||||
uv add ../autobangumi_sdk-0.6.0-py3-none-any.whl # use the real path of the wheel
|
||||
uv run pytest # the skeleton includes a contract test
|
||||
```
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
`ab-plugin` is installed with the `autobangumi-sdk` wheel. It depends only on `ab_sdk`. You do not need to install AutoBangumi.
|
||||
|
||||
```bash
|
||||
uv tool install ./autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
# or in a project: uv add ./autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
uv tool install ./autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
# or in a project: uv add ./autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
The wheel is an attachment of the 4.0 beta and stable GitHub releases. It is not on PyPI. Refer to [Get the SDK](/en/dev/plugins/sdk). The contract tests need pytest. The `pyproject.toml` that `new` creates already has pytest in its `dev` dependency group. For a project that you make yourself, use `uv add --dev pytest` (or install `autobangumi-sdk[test]`).
|
||||
@@ -65,7 +65,7 @@ ab-plugin dev [path] [--config-dir config]
|
||||
```bash
|
||||
ab-plugin new my-notify --kind notifier
|
||||
cd my-notify
|
||||
uv add ../autobangumi_sdk-0.5.0-py3-none-any.whl # one time only
|
||||
uv add ../autobangumi_sdk-0.6.0-py3-none-any.whl # one time only
|
||||
uv run pytest # contract tests
|
||||
ab-plugin dev . --config-dir /path/to/autobangumi/config # link and enable hot reload; restart AB one time
|
||||
# change code -> AB reloads -> check in the WebUI
|
||||
|
||||
@@ -27,6 +27,7 @@ class MyPlugin(Plugin):
|
||||
## Notes
|
||||
|
||||
- `ProviderInfo` drives the frontend form and the provider list. `auth_kind` is `api_key`, `oauth` or `device_code`.
|
||||
- An adapter gets the model name, key, `base_url`, timeout and a proxy-aware httpx client factory through `AdapterContext`. It does not read the global configuration.
|
||||
- An adapter gets the model name, key, `base_url`, timeout and a proxy-aware httpx2 client factory through `AdapterContext`. It does not read the global configuration.
|
||||
- The factory returns an `httpx2.AsyncClient` (since SDK 0.6; before, it was `httpx`). To catch network errors, use `httpx2.HTTPError` and related classes. The `httpx` exception classes do not catch its errors.
|
||||
- A subscription-type provider (`oauth` / `device_code`) implements the auth flow hooks (`AuthChallenge`, `TokenSet`). When the credentials are no longer valid and the refresh fails, raise `AuthExpiredError`. AB then trips the breaker for this provider and sends an `llm_auth_failure` event.
|
||||
- Existing LLM plugins in the `plugin.json` format (released as `llm-plugins`) still work. New plugins use `plugin.toml` and this extension point.
|
||||
|
||||
@@ -7,16 +7,16 @@ The plugin SDK is not on PyPI. Each 4.0 beta and stable [GitHub release](https:/
|
||||
| `autobangumi_sdk-<SDK version>-py3-none-any.whl` | The `ab_sdk` package and the `ab-plugin` command |
|
||||
| `autobangumi-plugin-skill-<AB version>.zip` | A plugin-development skill for AI coding assistants |
|
||||
|
||||
The wheel file name contains the SDK version (`ab_sdk.SDK_VERSION`, for example `0.5.0`). It does not contain the AB version. Download the wheel from the release of your target AB version, so that the two SDK versions are the same. The `sdk` range in the plugin manifest (for example `">=0.5,<1"`) must include this version.
|
||||
The wheel file name contains the SDK version (`ab_sdk.SDK_VERSION`, for example `0.6.0`). It does not contain the AB version. Download the wheel from the release of your target AB version, so that the two SDK versions are the same. The `sdk` range in the plugin manifest (for example `">=0.5,<1"`) must include this version.
|
||||
|
||||
## Install the wheel
|
||||
|
||||
The wheel needs Python 3.13 or later. It depends on `pydantic`, `httpx` and `packaging`. You do not need to install AutoBangumi.
|
||||
The wheel needs Python 3.13 or later. It depends on `pydantic`, `httpx2` and `packaging`. You do not need to install AutoBangumi.
|
||||
|
||||
To use only the command line, install the wheel as a global tool:
|
||||
|
||||
```bash
|
||||
uv tool install ./autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
uv tool install ./autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
ab-plugin --help
|
||||
```
|
||||
|
||||
@@ -24,7 +24,7 @@ To write a plugin and run its tests, add the wheel as a dependency of the plugin
|
||||
|
||||
```bash
|
||||
cd my-plugin
|
||||
uv add ../autobangumi_sdk-0.5.0-py3-none-any.whl
|
||||
uv add ../autobangumi_sdk-0.6.0-py3-none-any.whl
|
||||
uv run pytest
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user