Skip to content

Commit dbeadb6

Browse files
committed
refactor: remove Anthropic OAuth provider implementation and related metadata overrides
1 parent 478cc32 commit dbeadb6

File tree

7 files changed

+1
-182
lines changed

7 files changed

+1
-182
lines changed

astrbot/core/config/default.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -981,18 +981,6 @@ class ChatProviderTemplate(TypedDict):
981981
"proxy": "",
982982
"anth_thinking_config": {"type": "", "budget": 0, "effort": ""},
983983
},
984-
"Anthropic (Claude Code OAuth)": {
985-
"id": "anthropic_claude_code_oauth",
986-
"provider": "anthropic",
987-
"type": "anthropic_oauth",
988-
"provider_type": "chat_completion",
989-
"enable": True,
990-
"api_base": "https://api.anthropic.com",
991-
"timeout": 120,
992-
"proxy": "",
993-
"anth_thinking_config": {"type": "", "budget": 0, "effort": ""},
994-
"key": [],
995-
},
996984
"Moonshot": {
997985
"id": "moonshot",
998986
"provider": "moonshot",

astrbot/core/provider/manager.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ def dynamic_import_provider(self, type: str) -> None:
309309
from .sources.anthropic_source import (
310310
ProviderAnthropic as ProviderAnthropic,
311311
)
312-
case "anthropic_oauth":
313-
from .sources.anthropic_oauth_source import (
314-
ProviderAnthropicOAuth as ProviderAnthropicOAuth,
315-
)
316312
case "googlegenai_chat_completion":
317313
from .sources.gemini_source import (
318314
ProviderGoogleGenAI as ProviderGoogleGenAI,

astrbot/core/provider/sources/anthropic_oauth_source.py

Lines changed: 0 additions & 140 deletions
This file was deleted.

astrbot/dashboard/routes/config.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,6 @@
4040
MAX_FILE_BYTES = 500 * 1024 * 1024
4141

4242

43-
def _apply_provider_metadata_overrides(
44-
provider: Any, model_ids: list[str], metadata_map: dict
45-
) -> None:
46-
override_fn = getattr(provider, "get_model_metadata_overrides", None)
47-
if not callable(override_fn):
48-
return
49-
overrides_map = override_fn(model_ids) or {}
50-
for mid, overrides in overrides_map.items():
51-
merged = dict(metadata_map.get(mid, {}))
52-
for key, value in overrides.items():
53-
if isinstance(value, dict):
54-
merged[key] = {**merged.get(key, {}), **value}
55-
else:
56-
merged[key] = value
57-
metadata_map[mid] = merged
58-
59-
6043
def try_cast(value: Any, type_: str):
6144
if type_ == "int":
6245
try:
@@ -744,8 +727,6 @@ async def get_provider_model_list(self):
744727
if meta:
745728
metadata_map[model_id] = meta
746729

747-
_apply_provider_metadata_overrides(provider, models, metadata_map)
748-
749730
ret = {
750731
"models": models,
751732
"provider_id": provider_id,
@@ -891,8 +872,6 @@ async def get_provider_source_models(self):
891872
if meta:
892873
metadata_map[model_id] = meta
893874

894-
_apply_provider_metadata_overrides(inst, models, metadata_map)
895-
896875
# 销毁实例(如果有 terminate 方法)
897876
terminate_fn = getattr(inst, "terminate", None)
898877
if inspect.iscoroutinefunction(terminate_fn):

dashboard/src/composables/useProviderSources.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@ export function useProviderSources(options: UseProviderSourcesOptions) {
241241
// 为 provider source 的 id 字段添加自定义 hint
242242
if (customSchema.provider?.items?.id) {
243243
customSchema.provider.items.id.hint = tm('providerSources.hints.id')
244-
customSchema.provider.items.key.hint = editableProviderSource.value?.type === 'anthropic_oauth'
245-
? tm('providerSources.hints.oauthToken')
246-
: tm('providerSources.hints.key')
244+
customSchema.provider.items.key.hint = tm('providerSources.hints.key')
247245
customSchema.provider.items.api_base.hint = tm('providerSources.hints.apiBase')
248246
}
249247
// 为 proxy 字段添加描述和提示

dashboard/src/i18n/locales/en-US/features/provider.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
"hints": {
115115
"id": "Provider source ID (not provider ID)",
116116
"key": "API key for authentication",
117-
"oauthToken": "Run `claude setup-token` in your terminal to get a long-lived OAuth token, then paste it here. Token is valid for 1 year.",
118117
"apiBase": "Custom API endpoint URL",
119118
"proxy": "HTTP/HTTPS proxy address, e.g. http://127.0.0.1:7890. Only affects this provider's API requests, doesn't interfere with Docker internal networking."
120119
},

dashboard/src/i18n/locales/zh-CN/features/provider.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
"hints": {
116116
"id": "提供商源唯一 ID(不是提供商 ID)",
117117
"key": "API 密钥",
118-
"oauthToken": "在终端运行 `claude setup-token` 获取长期有效的 OAuth Token,然后粘贴到此处。Token 有效期为 1 年。",
119118
"apiBase": "自定义 API 端点 URL",
120119
"proxy": "HTTP/HTTPS 代理地址,格式如 http://127.0.0.1:7890。仅对该提供商的 API 请求生效,不影响 Docker 内网通信。"
121120
},

0 commit comments

Comments
 (0)