mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-11-27 17:00:37 +00:00
feat(setup): add keyless Rapid-MLX wizard entry (#8476)
* feat(setup): add keyless Rapid-MLX wizard entry Signed-off-by: nothingyuancando <1579035512@qq.com> * style(setup): drop unrelated writer formatting changes Signed-off-by: nothingyuancando <1579035512@qq.com> --------- Signed-off-by: nothingyuancando <1579035512@qq.com>
This commit is contained in:
parent
7314535539
commit
8744c9c9ac
@ -6,6 +6,7 @@ Run from repo root:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
import yaml
|
||||
from wizard import ui as wizard_ui
|
||||
from wizard.providers import LLM_PROVIDERS, SEARCH_PROVIDERS, WEB_FETCH_PROVIDERS, LLMProvider, with_thinking_support
|
||||
@ -483,6 +484,55 @@ class TestThinkingSupport:
|
||||
|
||||
|
||||
class TestLLMStep:
|
||||
@pytest.mark.parametrize("override", [False, True])
|
||||
def test_rapid_mlx_keyless_config(self, monkeypatch, tmp_path, override):
|
||||
provider_index = next(i for i, p in enumerate(LLM_PROVIDERS) if p.name == "rapid_mlx")
|
||||
monkeypatch.setattr(llm_step, "ask_choice", lambda *_args, **_kwargs: provider_index)
|
||||
prompts = []
|
||||
|
||||
def ask_text(prompt, default="", **_kwargs):
|
||||
prompts.append((prompt, default))
|
||||
if override:
|
||||
return "http://host.docker.internal:8000/v1" if len(prompts) == 1 else "my-exact-model-id"
|
||||
return default
|
||||
|
||||
monkeypatch.setattr(llm_step, "ask_text", ask_text)
|
||||
monkeypatch.setattr(
|
||||
llm_step,
|
||||
"ask_secret",
|
||||
lambda *_args: pytest.fail("keyless provider requested a secret"),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
llm_step,
|
||||
"ask_yes_no",
|
||||
lambda *_args, **_kwargs: pytest.fail("unexpected capability prompt"),
|
||||
)
|
||||
result = llm_step.run_llm_step()
|
||||
assert prompts == [
|
||||
("Rapid-MLX base URL", "http://127.0.0.1:8000/v1"),
|
||||
("Exact model ID from GET /v1/models", "qwen3.5-4b-4bit"),
|
||||
]
|
||||
assert result.api_key is None
|
||||
assert result.provider.env_var is None
|
||||
config_path = tmp_path / "config.yaml"
|
||||
write_config_yaml(
|
||||
config_path,
|
||||
provider_use=result.provider.use,
|
||||
model_name=result.model_name,
|
||||
display_name=result.provider.display_name,
|
||||
api_key_field=result.provider.api_key_field,
|
||||
env_var=result.provider.env_var,
|
||||
extra_model_config=result.provider.extra_config_for(result.model_name),
|
||||
base_url=result.base_url,
|
||||
)
|
||||
model = yaml.safe_load(config_path.read_text())["models"][0]
|
||||
assert model["use"] == "langchain_openai:ChatOpenAI"
|
||||
assert model["api_key"] == "not-required"
|
||||
assert model["base_url"] == ("http://host.docker.internal:8000/v1" if override else "http://127.0.0.1:8000/v1")
|
||||
assert model["model"] == ("my-exact-model-id" if override else "qwen3.5-4b-4bit")
|
||||
assert not any(key in model for key in ("supports_thinking", "supports_vision", "reasoning"))
|
||||
assert LLM_PROVIDERS[provider_index].extra_config["base_url"] == "http://127.0.0.1:8000/v1"
|
||||
|
||||
def test_model_selection_defaults_to_provider_default_model(self, monkeypatch):
|
||||
provider = LLMProvider(
|
||||
name="test",
|
||||
|
||||
@ -501,3 +501,40 @@ and objects, so parsing does not silently change its value. Python-literal sets
|
||||
and tuples containing non-finite floats also retain the complete argument as
|
||||
text, including when nested in other containers. Dictionary keys and values
|
||||
are checked recursively as well.
|
||||
|
||||
## Rapid-MLX on Apple Silicon
|
||||
|
||||
[Rapid-MLX](https://github.com/raullenchai/Rapid-MLX) exposes an
|
||||
OpenAI-compatible local endpoint. After installing it, start a server with an
|
||||
explicit port (omitting the port allows the server to choose another free port):
|
||||
|
||||
```bash
|
||||
rapid-mlx serve qwen3.5-4b-4bit --port 8000
|
||||
curl http://127.0.0.1:8000/v1/models
|
||||
```
|
||||
|
||||
Run `make setup` and select **Rapid-MLX (local)**. Accept or edit the default
|
||||
`http://127.0.0.1:8000/v1` endpoint, then enter the exact model ID from the
|
||||
`data[].id` field returned by `/v1/models`. The wizard skips secret input and
|
||||
writes a non-secret `api_key: not-required` placeholder for the OpenAI client;
|
||||
no API-key environment variable is needed. It does not infer vision or reasoning
|
||||
capabilities from the server name.
|
||||
|
||||
Equivalent manual model configuration:
|
||||
|
||||
```yaml
|
||||
models:
|
||||
- name: rapid-mlx-local
|
||||
display_name: Rapid-MLX (local)
|
||||
use: langchain_openai:ChatOpenAI
|
||||
model: <exact model ID from /v1/models>
|
||||
base_url: http://127.0.0.1:8000/v1
|
||||
api_key: not-required
|
||||
```
|
||||
|
||||
For containerized DeerFlow, loopback refers to the container. Use a host-reachable
|
||||
endpoint such as `http://host.docker.internal:8000/v1` on Docker Desktop, and
|
||||
configure the server to listen on an interface reachable from that container.
|
||||
For Web setup, use **Custom OpenAI-compatible** with the same endpoint and model
|
||||
ID; no separate managed-provider preset is required. Streaming and tool calling
|
||||
depend on the selected model and server; check both before using it for agent tasks.
|
||||
|
||||
@ -536,6 +536,23 @@ LLM_PROVIDERS: list[LLMProvider] = [
|
||||
"temperature": 0.7,
|
||||
},
|
||||
),
|
||||
LLMProvider(
|
||||
name="rapid_mlx",
|
||||
display_name="Rapid-MLX (local)",
|
||||
description="OpenAI-compatible local inference on Apple Silicon",
|
||||
use="langchain_openai:ChatOpenAI",
|
||||
models=["qwen3.5-4b-4bit"],
|
||||
default_model="qwen3.5-4b-4bit",
|
||||
env_var=None,
|
||||
package="langchain-openai",
|
||||
extra_config={
|
||||
"base_url": "http://127.0.0.1:8000/v1",
|
||||
"api_key": "not-required",
|
||||
},
|
||||
base_url_prompt="Rapid-MLX base URL",
|
||||
model_prompt="Exact model ID from GET /v1/models",
|
||||
auth_hint="Rapid-MLX requires no API key. A non-secret placeholder is used by the OpenAI client.",
|
||||
),
|
||||
LLMProvider(
|
||||
name="vllm",
|
||||
display_name="vLLM",
|
||||
|
||||
@ -43,9 +43,7 @@ def run_llm_step(step_label: str = "Step 1/3") -> LLMStepResult:
|
||||
model_name = provider.models[0]
|
||||
|
||||
print()
|
||||
base_url: str | None = None
|
||||
if provider.name in {"openrouter", "vllm"}:
|
||||
base_url = provider.extra_config.get("base_url")
|
||||
base_url: str | None = provider.extra_config.get("base_url")
|
||||
|
||||
if provider.base_url_prompt:
|
||||
print_header(f"{step_label} · Connection details")
|
||||
|
||||
@ -210,8 +210,8 @@ def build_minimal_config(
|
||||
if env_var:
|
||||
model_entry[api_key_field] = f"${env_var}"
|
||||
extra_model_fields = dict(extra_model_config or {})
|
||||
if "base_url" in extra_model_fields and not base_url:
|
||||
base_url = extra_model_fields.pop("base_url")
|
||||
configured_base_url = extra_model_fields.pop("base_url", None)
|
||||
base_url = base_url or configured_base_url
|
||||
if base_url:
|
||||
model_entry["base_url"] = base_url
|
||||
if extra_model_fields:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user