AgentWard icon indicating copy to clipboard operation
AgentWard copied to clipboard

/core/state.ts中可以添加对配置文件中provider一段中headers的支持

Open woodlyer opened this issue 7 months ago • 1 comments

在/core/state.ts中可以添加对配置文件中provider一段中headers的支持。

将provider的headers保存下来,然后放到llmContext中。

const providerConfig = config.models?.providers?.[provider];

  // 添加 headers
  const headers = providerConfig.headers;
  
  this.llmContext = {
    model,
    options: {
      apiKey: authInfo.apiKey,
      maxTokens: model.maxTokens || undefined,
      headers,  // 添加自定义 headers
    },
    apiKey: authInfo.apiKey,
    modelRef: this.defaultModelRef,
  };

有些models需要特殊的headers

  "models": {
    "mode": "merge",
    "providers": {
      "bailian": {
        "baseUrl": "http://localhost:8228/qwen",
        "apiKey": "sk-sp-123123123123123123123605b",
        "api": "openai-completions",
        "headers": {
            "LLM-BASE-URL": "https://coding.dashscope.aliyuncs.com/v1",
            "Abigbox-Authorization": "Bearer invsdfasdfasfdasdfadf4b5ec5"
        },
        "models": [
          {
            "id": "qwen3.5-plus",
            "name": "qwen3.5-plus",
            "api": "openai-completions",

woodlyer avatar Apr 16 '26 07:04 woodlyer

感谢建议,已更新支持。麻烦再次测试。

Bocchi7 avatar Apr 20 '26 12:04 Bocchi7