mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-20 16:42:25 +00:00
fix(providers): point Skywork at APIFree agent endpoint
This commit is contained in:
parent
6194a9b919
commit
eae51333ad
@ -154,7 +154,6 @@ ANTHROPIC_API_KEY="$(bw get password api/anthropic)" nanobot agent
|
|||||||
| `mimo` | LLM (MiMo) | [platform.xiaomimimo.com](https://platform.xiaomimimo.com) |
|
| `mimo` | LLM (MiMo) | [platform.xiaomimimo.com](https://platform.xiaomimimo.com) |
|
||||||
| `longcat` | LLM (LongCat) | [longcat.chat](https://longcat.chat/platform/docs/zh/) |
|
| `longcat` | LLM (LongCat) | [longcat.chat](https://longcat.chat/platform/docs/zh/) |
|
||||||
| `ant_ling` | LLM (Ant Ling / 蚂蚁百灵) | [developer.ant-ling.com](https://developer.ant-ling.com/en/docs/api-reference/openai/) |
|
| `ant_ling` | LLM (Ant Ling / 蚂蚁百灵) | [developer.ant-ling.com](https://developer.ant-ling.com/en/docs/api-reference/openai/) |
|
||||||
| `apifree` | LLM (APIFree) | [apifree.ai](https://www.apifree.ai) |
|
|
||||||
| `ollama` | LLM (local, Ollama) | — |
|
| `ollama` | LLM (local, Ollama) | — |
|
||||||
| `lm_studio` | LLM (local, LM Studio) | — |
|
| `lm_studio` | LLM (local, LM Studio) | — |
|
||||||
| `atomic_chat` | LLM (local, [Atomic Chat](https://atomic.chat/)) | — |
|
| `atomic_chat` | LLM (local, [Atomic Chat](https://atomic.chat/)) | — |
|
||||||
@ -169,7 +168,7 @@ ANTHROPIC_API_KEY="$(bw get password api/anthropic)" nanobot agent
|
|||||||
<details>
|
<details>
|
||||||
<summary><b>Skywork / APIFree</b></summary>
|
<summary><b>Skywork / APIFree</b></summary>
|
||||||
|
|
||||||
Skywork uses the OpenAI-compatible APIFree API endpoint. Configure the provider
|
Skywork uses APIFree's OpenAI-compatible Agent API endpoint. Configure the provider
|
||||||
once, then use Skywork model IDs such as `skywork-ai/skyclaw-v1`.
|
once, then use Skywork model IDs such as `skywork-ai/skyclaw-v1`.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@ -177,7 +176,7 @@ once, then use Skywork model IDs such as `skywork-ai/skyclaw-v1`.
|
|||||||
"providers": {
|
"providers": {
|
||||||
"skywork": {
|
"skywork": {
|
||||||
"apiKey": "${SKYWORK_API_KEY}",
|
"apiKey": "${SKYWORK_API_KEY}",
|
||||||
"apiBase": "https://api.apifree.ai/v1"
|
"apiBase": "https://api.apifree.ai/agent/v1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"agents": {
|
"agents": {
|
||||||
@ -505,31 +504,6 @@ Official OpenAI-compatible model names include `Ling-2.6-1T`,
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary><b>APIFree (OpenAI-compatible)</b></summary>
|
|
||||||
|
|
||||||
APIFree is available through nanobot's built-in OpenAI-compatible provider flow. The default API base points to `https://api.apifree.ai/agent/v1`, so you usually only need to set `apiKey`.
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"providers": {
|
|
||||||
"apifree": {
|
|
||||||
"apiKey": "${APIFREE_API_KEY}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"agents": {
|
|
||||||
"defaults": {
|
|
||||||
"provider": "apifree",
|
|
||||||
"model": "skywork-ai/skyclaw-v1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Available models include `skywork-ai/skyclaw-v1`.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><b>Custom Provider (Any OpenAI-compatible API)</b></summary>
|
<summary><b>Custom Provider (Any OpenAI-compatible API)</b></summary>
|
||||||
|
|
||||||
|
|||||||
@ -209,7 +209,6 @@ class ProvidersConfig(Base):
|
|||||||
xiaomi_mimo: ProviderConfig = Field(default_factory=ProviderConfig) # Xiaomi MIMO (小米)
|
xiaomi_mimo: ProviderConfig = Field(default_factory=ProviderConfig) # Xiaomi MIMO (小米)
|
||||||
longcat: ProviderConfig = Field(default_factory=ProviderConfig) # LongCat
|
longcat: ProviderConfig = Field(default_factory=ProviderConfig) # LongCat
|
||||||
ant_ling: ProviderConfig = Field(default_factory=ProviderConfig) # Ant Ling
|
ant_ling: ProviderConfig = Field(default_factory=ProviderConfig) # Ant Ling
|
||||||
apifree: ProviderConfig = Field(default_factory=ProviderConfig) # APIFree
|
|
||||||
aihubmix: ProviderConfig = Field(default_factory=ProviderConfig) # AiHubMix API gateway
|
aihubmix: ProviderConfig = Field(default_factory=ProviderConfig) # AiHubMix API gateway
|
||||||
siliconflow: ProviderConfig = Field(default_factory=ProviderConfig) # SiliconFlow (硅基流动)
|
siliconflow: ProviderConfig = Field(default_factory=ProviderConfig) # SiliconFlow (硅基流动)
|
||||||
volcengine: ProviderConfig = Field(default_factory=ProviderConfig) # VolcEngine (火山引擎)
|
volcengine: ProviderConfig = Field(default_factory=ProviderConfig) # VolcEngine (火山引擎)
|
||||||
|
|||||||
@ -165,7 +165,7 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
|
|||||||
env_extras=(("APIFREE_API_KEY", "{api_key}"),),
|
env_extras=(("APIFREE_API_KEY", "{api_key}"),),
|
||||||
is_gateway=True,
|
is_gateway=True,
|
||||||
detect_by_base_keyword="apifree.ai",
|
detect_by_base_keyword="apifree.ai",
|
||||||
default_api_base="https://api.apifree.ai/v1",
|
default_api_base="https://api.apifree.ai/agent/v1",
|
||||||
),
|
),
|
||||||
# AiHubMix: global gateway, OpenAI-compatible interface.
|
# AiHubMix: global gateway, OpenAI-compatible interface.
|
||||||
# strip_model_prefix=True: doesn't understand "anthropic/claude-3",
|
# strip_model_prefix=True: doesn't understand "anthropic/claude-3",
|
||||||
@ -412,16 +412,6 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
|
|||||||
detect_by_base_keyword="ant-ling.com",
|
detect_by_base_keyword="ant-ling.com",
|
||||||
default_api_base="https://api.ant-ling.com/v1",
|
default_api_base="https://api.ant-ling.com/v1",
|
||||||
),
|
),
|
||||||
# APIFree: OpenAI-compatible API gateway with agent-optimised models.
|
|
||||||
ProviderSpec(
|
|
||||||
name="apifree",
|
|
||||||
keywords=("apifree", "api-free", "skyclaw"),
|
|
||||||
env_key="APIFREE_API_KEY",
|
|
||||||
display_name="APIFree",
|
|
||||||
backend="openai_compat",
|
|
||||||
detect_by_base_keyword="apifree.ai",
|
|
||||||
default_api_base="https://api.apifree.ai/agent/v1",
|
|
||||||
),
|
|
||||||
# === Local deployment (matched by config key, NOT by api_base) =========
|
# === Local deployment (matched by config key, NOT by api_base) =========
|
||||||
# vLLM / any OpenAI-compatible local server
|
# vLLM / any OpenAI-compatible local server
|
||||||
ProviderSpec(
|
ProviderSpec(
|
||||||
|
|||||||
@ -1031,11 +1031,9 @@ async def test_settings_api_returns_safe_subset_and_updates_whitelist(
|
|||||||
assert providers["openrouter"]["configured"] is False
|
assert providers["openrouter"]["configured"] is False
|
||||||
assert providers["openrouter"]["api_key_required"] is True
|
assert providers["openrouter"]["api_key_required"] is True
|
||||||
assert providers["skywork"]["label"] == "Skywork"
|
assert providers["skywork"]["label"] == "Skywork"
|
||||||
assert providers["skywork"]["default_api_base"] == "https://api.apifree.ai/v1"
|
assert providers["skywork"]["default_api_base"] == "https://api.apifree.ai/agent/v1"
|
||||||
assert providers["ant_ling"]["label"] == "Ant Ling"
|
assert providers["ant_ling"]["label"] == "Ant Ling"
|
||||||
assert providers["ant_ling"]["default_api_base"] == "https://api.ant-ling.com/v1"
|
assert providers["ant_ling"]["default_api_base"] == "https://api.ant-ling.com/v1"
|
||||||
assert providers["apifree"]["label"] == "APIFree"
|
|
||||||
assert providers["apifree"]["default_api_base"] == "https://api.apifree.ai/agent/v1"
|
|
||||||
assert providers["atomic_chat"]["configured"] is False
|
assert providers["atomic_chat"]["configured"] is False
|
||||||
assert providers["atomic_chat"]["api_key_required"] is False
|
assert providers["atomic_chat"]["api_key_required"] is False
|
||||||
assert providers["atomic_chat"]["default_api_base"] == "http://localhost:1337/v1"
|
assert providers["atomic_chat"]["default_api_base"] == "http://localhost:1337/v1"
|
||||||
|
|||||||
@ -1,71 +0,0 @@
|
|||||||
"""Tests for the APIFree provider registration."""
|
|
||||||
|
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from nanobot.config.schema import Config, ProvidersConfig
|
|
||||||
from nanobot.providers.openai_compat_provider import OpenAICompatProvider
|
|
||||||
from nanobot.providers.registry import PROVIDERS, find_by_name
|
|
||||||
|
|
||||||
|
|
||||||
def test_apifree_config_field_exists() -> None:
|
|
||||||
config = ProvidersConfig()
|
|
||||||
assert hasattr(config, "apifree")
|
|
||||||
|
|
||||||
|
|
||||||
def test_apifree_provider_in_registry() -> None:
|
|
||||||
specs = {spec.name: spec for spec in PROVIDERS}
|
|
||||||
assert "apifree" in specs
|
|
||||||
|
|
||||||
apifree = specs["apifree"]
|
|
||||||
assert apifree.backend == "openai_compat"
|
|
||||||
assert apifree.env_key == "APIFREE_API_KEY"
|
|
||||||
assert apifree.display_name == "APIFree"
|
|
||||||
assert apifree.default_api_base == "https://api.apifree.ai/agent/v1"
|
|
||||||
|
|
||||||
|
|
||||||
def test_find_by_name_accepts_apifree_spellings() -> None:
|
|
||||||
spec = find_by_name("apifree")
|
|
||||||
assert spec is not None
|
|
||||||
|
|
||||||
|
|
||||||
def test_apifree_model_auto_matches_with_default_api_base() -> None:
|
|
||||||
config = Config.model_validate(
|
|
||||||
{
|
|
||||||
"providers": {
|
|
||||||
"apifree": {
|
|
||||||
"apiKey": "apifree-key",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"agents": {
|
|
||||||
"defaults": {
|
|
||||||
"model": "skywork-ai/skyclaw-v1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
assert config.get_provider_name("skywork-ai/skyclaw-v1") == "apifree"
|
|
||||||
assert config.get_api_key("skywork-ai/skyclaw-v1") == "apifree-key"
|
|
||||||
assert config.get_api_base("skywork-ai/skyclaw-v1") == "https://api.apifree.ai/agent/v1"
|
|
||||||
|
|
||||||
|
|
||||||
def test_apifree_preserves_official_model_name() -> None:
|
|
||||||
spec = find_by_name("apifree")
|
|
||||||
with patch("nanobot.providers.openai_compat_provider.AsyncOpenAI"):
|
|
||||||
provider = OpenAICompatProvider(
|
|
||||||
api_key="apifree-key",
|
|
||||||
default_model="skywork-ai/skyclaw-v1",
|
|
||||||
spec=spec,
|
|
||||||
)
|
|
||||||
|
|
||||||
kwargs = provider._build_kwargs(
|
|
||||||
messages=[{"role": "user", "content": "hi"}],
|
|
||||||
tools=None,
|
|
||||||
model="skywork-ai/skyclaw-v1",
|
|
||||||
max_tokens=1024,
|
|
||||||
temperature=0.7,
|
|
||||||
reasoning_effort=None,
|
|
||||||
tool_choice=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert kwargs["model"] == "skywork-ai/skyclaw-v1"
|
|
||||||
@ -24,7 +24,7 @@ def test_skywork_provider_in_registry() -> None:
|
|||||||
assert skywork.display_name == "Skywork"
|
assert skywork.display_name == "Skywork"
|
||||||
assert skywork.is_gateway is True
|
assert skywork.is_gateway is True
|
||||||
assert skywork.detect_by_base_keyword == "apifree.ai"
|
assert skywork.detect_by_base_keyword == "apifree.ai"
|
||||||
assert skywork.default_api_base == "https://api.apifree.ai/v1"
|
assert skywork.default_api_base == "https://api.apifree.ai/agent/v1"
|
||||||
assert skywork.supports_max_completion_tokens is False
|
assert skywork.supports_max_completion_tokens is False
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ def test_skywork_model_auto_matches_with_default_api_base() -> None:
|
|||||||
|
|
||||||
assert config.get_provider_name("skywork-ai/skyclaw-v1") == "skywork"
|
assert config.get_provider_name("skywork-ai/skyclaw-v1") == "skywork"
|
||||||
assert config.get_api_key("skywork-ai/skyclaw-v1") == "sky-key"
|
assert config.get_api_key("skywork-ai/skyclaw-v1") == "sky-key"
|
||||||
assert config.get_api_base("skywork-ai/skyclaw-v1") == "https://api.apifree.ai/v1"
|
assert config.get_api_base("skywork-ai/skyclaw-v1") == "https://api.apifree.ai/agent/v1"
|
||||||
|
|
||||||
|
|
||||||
def test_skywork_preserves_model_id_and_uses_chat_completion_max_tokens() -> None:
|
def test_skywork_preserves_model_id_and_uses_chat_completion_max_tokens() -> None:
|
||||||
|
|||||||
@ -2150,7 +2150,6 @@ const PROVIDER_ICONS: Record<string, LucideIcon> = {
|
|||||||
byteplus_coding_plan: Cloud,
|
byteplus_coding_plan: Cloud,
|
||||||
qianfan: Database,
|
qianfan: Database,
|
||||||
ant_ling: Sparkles,
|
ant_ling: Sparkles,
|
||||||
apifree: Sparkles,
|
|
||||||
azure_openai: Cloud,
|
azure_openai: Cloud,
|
||||||
bedrock: Database,
|
bedrock: Database,
|
||||||
vllm: Cpu,
|
vllm: Cpu,
|
||||||
|
|||||||
@ -580,13 +580,6 @@ describe("App layout", () => {
|
|||||||
api_key_required: true,
|
api_key_required: true,
|
||||||
default_api_base: "https://api.ant-ling.com/v1",
|
default_api_base: "https://api.ant-ling.com/v1",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "apifree",
|
|
||||||
label: "APIFree",
|
|
||||||
configured: false,
|
|
||||||
api_key_required: true,
|
|
||||||
default_api_base: "https://api.apifree.ai/agent/v1",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "azure_openai",
|
name: "azure_openai",
|
||||||
label: "Azure OpenAI",
|
label: "Azure OpenAI",
|
||||||
@ -746,7 +739,6 @@ describe("App layout", () => {
|
|||||||
fireEvent.click(within(settingsNav).getByRole("button", { name: "Providers" }));
|
fireEvent.click(within(settingsNav).getByRole("button", { name: "Providers" }));
|
||||||
expect(screen.getByText("OpenRouter")).toBeInTheDocument();
|
expect(screen.getByText("OpenRouter")).toBeInTheDocument();
|
||||||
expect(screen.getByText("Ant Ling")).toBeInTheDocument();
|
expect(screen.getByText("Ant Ling")).toBeInTheDocument();
|
||||||
expect(screen.getByText("APIFree")).toBeInTheDocument();
|
|
||||||
expect(screen.getAllByText("Not configured").length).toBeGreaterThan(0);
|
expect(screen.getAllByText("Not configured").length).toBeGreaterThan(0);
|
||||||
fireEvent.click(screen.getByText("OpenAI"));
|
fireEvent.click(screen.getByText("OpenAI"));
|
||||||
fireEvent.click(screen.getByRole("button", { name: "Edit" }));
|
fireEvent.click(screen.getByRole("button", { name: "Edit" }));
|
||||||
@ -759,8 +751,6 @@ describe("App layout", () => {
|
|||||||
expect(screen.queryByDisplayValue("unsaved-openai-key")).not.toBeInTheDocument();
|
expect(screen.queryByDisplayValue("unsaved-openai-key")).not.toBeInTheDocument();
|
||||||
fireEvent.click(screen.getByText("Ant Ling"));
|
fireEvent.click(screen.getByText("Ant Ling"));
|
||||||
expect(screen.getByDisplayValue("https://api.ant-ling.com/v1")).toBeInTheDocument();
|
expect(screen.getByDisplayValue("https://api.ant-ling.com/v1")).toBeInTheDocument();
|
||||||
fireEvent.click(screen.getByText("APIFree"));
|
|
||||||
expect(screen.getByDisplayValue("https://api.apifree.ai/agent/v1")).toBeInTheDocument();
|
|
||||||
fireEvent.click(screen.getByText("Atomic Chat"));
|
fireEvent.click(screen.getByText("Atomic Chat"));
|
||||||
expect(screen.getByDisplayValue("http://localhost:1337/v1")).toBeInTheDocument();
|
expect(screen.getByDisplayValue("http://localhost:1337/v1")).toBeInTheDocument();
|
||||||
expect(screen.getByRole("button", { name: "Save" })).toBeEnabled();
|
expect(screen.getByRole("button", { name: "Save" })).toBeEnabled();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user