x
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
- `services.openai.host` / `services.openai.port`:OpenAI 协议服务监听地址与端口(默认 `0.0.0.0:8001`)
|
||||
- `public_model_name`:对外固定模型名,切换底层模型时可保持调用方参数不变
|
||||
- `reasoning_enabled`:思考推理开关,默认 `false`(关闭)
|
||||
- `reasoning_enabled`:是否启用推理解析器参数注入,默认 `false`
|
||||
- `api_key`:OpenAI 接口访问密钥
|
||||
- `tensor_parallel_size`:张量并行数,双卡建议 `2`
|
||||
- `dtype`:推理精度,默认 `bfloat16`
|
||||
@@ -84,7 +84,7 @@ curl http://localhost:<services.openai.port>/v1/models
|
||||
curl -X POST "http://localhost:8001/v1/chat/completions" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer <config.json中的api_key>" \
|
||||
-d "{\"model\":\"Qwen_local_model\",\"messages\":[{\"role\":\"user\",\"content\":\"你好,介绍一下你自己\"}],\"temperature\":0.7}"
|
||||
-d "{\"model\":\"Qwen_local_model\",\"messages\":[{\"role\":\"user\",\"content\":\"你好,介绍一下你自己\"}],\"temperature\":0.7,\"chat_template_kwargs\":{\"enable_thinking\":false}}"
|
||||
```
|
||||
|
||||
## OpenClaw 调用说明
|
||||
@@ -92,7 +92,8 @@ curl -X POST "http://localhost:8001/v1/chat/completions" \
|
||||
- Base URL 使用 `http://<服务器IP>:8001/v1`
|
||||
- API Key 使用 `config.json` 中 `api_key`
|
||||
- 模型名固定使用 `config.json` 中 `public_model_name`(默认 `Qwen_local_model`)
|
||||
- 若要启用思考推理,将 `config.json` 中 `reasoning_enabled` 设为 `true`
|
||||
- 思考模式按请求控制:`chat_template_kwargs.enable_thinking=false/true`
|
||||
- 仅当模型需要推理解析器时,再将 `config.json` 中 `reasoning_enabled` 设为 `true`
|
||||
- 若使用工具调用,`config.json` 中应配置 `tool_call_parser` 与 `enable_auto_tool_choice`
|
||||
- 服务强制离线模式,不会回退到 Hugging Face 远程下载
|
||||
- 所有路径按 Ubuntu 规范填写,本地模型建议使用 `/opt/model/<模型目录>`
|
||||
|
||||
@@ -17,6 +17,7 @@ class Settings(BaseModel):
|
||||
port: int = 8000
|
||||
openai_host: str = "0.0.0.0"
|
||||
openai_port: int = 8001
|
||||
vllm_openai_internal_url: str = "http://127.0.0.1:8001/v1"
|
||||
public_model_name: str = "Qwen_local_model"
|
||||
reasoning_enabled: bool = False
|
||||
model_root: str = "/opt/model"
|
||||
@@ -46,6 +47,7 @@ def get_settings() -> Settings:
|
||||
port=runtime["port"],
|
||||
openai_host=runtime["openai_host"],
|
||||
openai_port=runtime["openai_port"],
|
||||
vllm_openai_internal_url=runtime["vllm_openai_internal_url"],
|
||||
public_model_name=runtime["public_model_name"],
|
||||
reasoning_enabled=runtime["reasoning_enabled"],
|
||||
model_root=runtime["model_root"],
|
||||
|
||||
@@ -25,6 +25,8 @@ class InferenceEngine:
|
||||
}
|
||||
if req.stop:
|
||||
payload["stop"] = req.stop
|
||||
if req.enable_thinking is not None:
|
||||
payload["chat_template_kwargs"] = {"enable_thinking": req.enable_thinking}
|
||||
response = self.client.post(
|
||||
f"{self.settings.vllm_openai_internal_url}/chat/completions",
|
||||
headers=headers,
|
||||
|
||||
@@ -63,11 +63,16 @@ def resolve_runtime_settings(content: dict[str, Any]) -> dict[str, Any]:
|
||||
api_service = dict(services.get("api", {}))
|
||||
openai_service = dict(services.get("openai", {}))
|
||||
models = dict(content.get("models", {}))
|
||||
openai_port = _to_int(openai_service.get("port"), 8001)
|
||||
internal_url = _to_str(content.get("vllm_openai_internal_url"))
|
||||
if not internal_url:
|
||||
internal_url = f"http://127.0.0.1:{openai_port}/v1"
|
||||
return {
|
||||
"host": str(api_service.get("host", "0.0.0.0")),
|
||||
"port": _to_int(api_service.get("port"), 8000),
|
||||
"openai_host": str(openai_service.get("host", "0.0.0.0")),
|
||||
"openai_port": _to_int(openai_service.get("port"), 8001),
|
||||
"openai_port": openai_port,
|
||||
"vllm_openai_internal_url": internal_url.rstrip("/"),
|
||||
"public_model_name": _to_str(content.get("public_model_name"), "Qwen_local_model"),
|
||||
"api_key": str(content.get("api_key", "")).strip() or None,
|
||||
"reasoning_enabled": _to_bool(content.get("reasoning_enabled"), False),
|
||||
|
||||
@@ -10,6 +10,7 @@ class GenerateRequest(BaseModel):
|
||||
top_p: float = Field(default=0.95, gt=0.0, le=1.0)
|
||||
repetition_penalty: float = Field(default=1.0, ge=0.5, le=2.0)
|
||||
stop: Optional[List[str]] = None
|
||||
enable_thinking: Optional[bool] = None
|
||||
|
||||
|
||||
class GenerateResponse(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user