Repository navigation
fix(ai): ensure Anthropic provider baseURL includes /v1 (#1248) - #1291
Open
Aniketchavan7 wants to merge 1 commit into
Open
Aniketchavan7 wants to merge 1 commit into
Aniketchavan7 wants to merge 1 commit into
Conversation
- Update Anthropic provider template defaultBaseURL to 'https://api.anthropic.com/v1' - Normalize custom Anthropic baseURL in LLMProvider to append /v1 if missing - Add unit tests for Anthropic baseURL normalization in LLMProvider Co-authored-by: yalongwastaken <yalongwastaken@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1248
Problem
When setting up Anthropic using the default provider template under Settings -> AI, the template defaulted
defaultBaseURLtohttps://api.anthropic.com.@ai-sdk/anthropicexpectsbaseURLto include the API version prefix (its internal default ishttps://api.anthropic.com/v1). Because passing the bare domain overrides that default without/v1, requests were dispatched tohttps://api.anthropic.com/messages, which returns HTTP 404 Not Found.Solution
PROVIDER_TEMPLATESinapp/src/components/BlinkoSettings/AiSetting/constants.tsxto setdefaultBaseURL: 'https://api.anthropic.com/v1'(matching OpenAI and Voyage templates).server/aiServer/providers/LLMProvider.ts: if a user supplies a custombaseURLwithout/v1(or previously saved the default without/v1), strip any trailing slash and append/v1.server/aiServer/providers/__tests__/anthropic-provider.test.tscovering baseURL normalization.Fixes #1248
问题
在“设置 -> AI”中使用默认提供商模板配置 Anthropic 时,模板中
defaultBaseURL默认填充为https://api.anthropic.com。@ai-sdk/anthropic要求baseURL包含 API 版本前缀(其内部默认值为https://api.anthropic.com/v1)。直接传入不含/v1的基础域名会覆盖此默认值,导致请求发送至https://api.anthropic.com/messages并返回 HTTP 404 Not Found。解决方案
app/src/components/BlinkoSettings/AiSetting/constants.tsx中的PROVIDER_TEMPLATES,将defaultBaseURL设置为https://api.anthropic.com/v1(与 OpenAI 和 Voyage 模板一致)。server/aiServer/providers/LLMProvider.ts中增加兼容性处理:如果用户配置的baseURL未包含/v1(或之前已保存未含/v1的地址),自动去除末尾斜杠并补全/v1。server/aiServer/providers/__tests__/anthropic-provider.test.ts中新增覆盖 Anthropic baseURL 规范化逻辑的单元测试。