wenzetan/dsh-llm-newapi2

dsh-llm-newapi

NewAPI (OpenAI-compatible gateway) chat-completions adapter for the DeepSeek Harness LLM seam. Provider route id 'newapi', display name 'NewAPI'. Dual-face: host half registers the LLM adapter and chat-only model discovery; browser half adds a NewAPI settings section to dsh web. The API key is configured on the web settings page (fixed credentials reference 'newapi'), never read from environment variables.

包名
dsh-llm-newapi
版本
0.8.2
许可证
MIT
最近更新
2026年8月15日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:wenzetan/dsh-llm-newapi

Configuration (cordis.yml entry config; after install the llm-newapi: section in settings.yaml hot-reloads and overrides it)

- id: llm-newapi
  name: dsh-llm-newapi
  config:
    baseURL: http://gw.local:3000/v1   # include the /v1 prefix; falls back to env NEWAPI_BASE_URL → placeholder
    # models:                          # suggested catalog; empty by default, use "Fetch model info" to pull /models
    #   - id: deepseek-chat
    #     contextWindow: 65536
    # modelExcludePatterns:            # chat-only filter during discovery (replaces the default wholesale)
    #   - embed                        #   default ['embed','rerank','ranker'] (case-insensitive id substring)
    #   - rerank                       #   set [] to disable the filter; multi-capability ids (bge-m3) must be added manually
    # defaultContextWindow: 128000     # context capacity when the catalog has no entry
    # maxTokens: 8192                  # when absent, max_tokens is not sent and each upstream default applies
    # providerHints:                   # official-vendor arbitration for models.dev parameter matching
    #   defaults:                      #   family prefix → provider (overrides built-ins like glm→zai)
    #     glm: zhipuai                 #   e.g. use the ZhipuAI open platform data instead
    #   models:                        #   per-id exact → provider (takes precedence over family)
    #     tencent/Hunyuan-MT-7B: nano-gpt

API key: not a config item — it lives under the fixed newapi reference in the credentials store, and its only configuration surface is the web settings page (takes effect immediately on write, resolved per request). The plugin never reads the key from environment variables: the top read-only layer of the credentials service is inherited from the environment, so a NEWAPI_API_KEY-style reference would be shadowed by an identically-named env var and lock the front-end input; hence the fixed reference name newapi. Without a key, the first request fails with MISSING_CREDENTIAL and points to the settings page — it never errors at load time.

Model discovery: GET {baseURL}/models; only models that can serve chat-completions are adopted — embedding / rerank / ranker families are filtered by naming convention (configurable).

Web settings page: discovered at runtime by dsh web through the dsh.client manifest (ClientModuleRegistry scans composition plugin lines), contributing a settings.section slot (dsh contract: features own their settings page, no shell changes). Note it is a standalone "NewAPI" page in the settings panel, not embedded inside the official Models page. Inputs and buttons all use --dsw-alias-* design tokens (same recipe as the official Models page), adapting automatically to light / dark themes.

Config validation: the settings write point rejects segments the adapter cannot serve (e.g. non-http(s) baseURL, empty filter entries) — constraints the schema cannot express are reported at write time, so you never get "saved successfully but silently kept old values".