Skip to content

fix: custom headers and compat for custom models - #456

Open
isWittHere wants to merge 1 commit into
agegr:mainfrom
isWittHere:feat/model-compat-headers-ui
Open

fix: custom headers and compat for custom models#456
isWittHere wants to merge 1 commit into
agegr:mainfrom
isWittHere:feat/model-compat-headers-ui

Conversation

@isWittHere

Copy link
Copy Markdown
Contributor

fix

自定义配置的模型供应商许多会拒绝pi默认使用的developer角色,该项修复在模型配置页面提供了自定义header选项和角色配置入口

Custom OpenAI-compatible endpoints frequently need per-request headers
(such as User-Agent for gateway bot detection) and a compat flag to
fall back to the system role when the server rejects the developer
role. Both previously required hand-editing ~/.pi/agent/models.json,
because the custom-model UI exposed no headers or generic compat entry.
image
image

Changes

New:

  • components/ModelsConfig.test.mjs — source-level tests asserting the
    editors are wired to the provider/model entries (27 lines)

Edited:

  • components/ModelsConfig.tsx — provider- and model-level headers
    editors, supportsDeveloperRole toggle that reads the effective
    provider-plus-model compat value and writes an explicit per-model
    override, ModelEntry.headers field (90 lines)

Net: 2 files, +117/−0

Notes for maintainers:

  • Form labels are hardcoded English to match the existing ModelsConfig
    convention ("API override", "DeepSeek thinking compat", ...). No i18n
    keys were added; happy to switch to models.* flat keys if preferred.
  • Session affinity flags (sendSessionAffinityHeaders /
    sessionAffinityFormat) are intentionally out of scope.

Testing

  • node_modules/.bin/tsc --noEmit — pass
  • npx eslint components/ModelsConfig.tsx — pass
  • node --test components/ModelsConfig.test.mjs — 2/2 pass

Custom OpenAI-compatible endpoints often need per-request headers
(such as User-Agent for gateway bot detection) and a compat flag to
fall back to the system role when the server rejects the developer
role. These previously required hand-editing models.json.

* headers editor at both provider and model level, with model-level
  values overriding the provider for that model
* supportsDeveloperRole toggle reads the effective provider-plus-model
  compat value and writes an explicit per-model override
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant