From 743df5159eda752cd425f802a03be650a66a98aa Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Sat, 7 Sep 2024 01:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20support=20anthropic=20b?= =?UTF-8?q?rowser=20request=20(#3798)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/config/modelProviders/anthropic.ts | 1 - src/libs/agent-runtime/anthropic/index.ts | 4 ++-- src/services/chat.ts | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 350afefbb2ec..ea07d95b135e 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "dependencies": { "@ant-design/icons": "^5.4.0", "@ant-design/pro-components": "^2.7.10", - "@anthropic-ai/sdk": "^0.24.3", + "@anthropic-ai/sdk": "^0.27.0", "@auth/core": "0.28.0", "@aws-sdk/client-bedrock-runtime": "^3.637.0", "@aws-sdk/client-s3": "^3.637.0", diff --git a/src/config/modelProviders/anthropic.ts b/src/config/modelProviders/anthropic.ts index 9d36c761bda8..dd3505d8c334 100644 --- a/src/config/modelProviders/anthropic.ts +++ b/src/config/modelProviders/anthropic.ts @@ -67,7 +67,6 @@ const Anthropic: ModelProviderCard = { }, ], checkModel: 'claude-3-haiku-20240307', - disableBrowserRequest: true, id: 'anthropic', name: 'Anthropic', proxyUrl: { diff --git a/src/libs/agent-runtime/anthropic/index.ts b/src/libs/agent-runtime/anthropic/index.ts index 0f02bf9700aa..0a99fb3bc61e 100644 --- a/src/libs/agent-runtime/anthropic/index.ts +++ b/src/libs/agent-runtime/anthropic/index.ts @@ -20,10 +20,10 @@ export class LobeAnthropicAI implements LobeRuntimeAI { baseURL: string; - constructor({ apiKey, baseURL = DEFAULT_BASE_URL }: ClientOptions = {}) { + constructor({ apiKey, baseURL = DEFAULT_BASE_URL, ...res }: ClientOptions = {}) { if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey); - this.client = new Anthropic({ apiKey, baseURL }); + this.client = new Anthropic({ apiKey, baseURL, ...res }); this.baseURL = this.client.baseURL; } diff --git a/src/services/chat.ts b/src/services/chat.ts index 3c9cb45ed155..cb4cf282375d 100644 --- a/src/services/chat.ts +++ b/src/services/chat.ts @@ -134,12 +134,14 @@ export function initializeWithClientStore(provider: string, payload: any) { case ModelProvider.Qwen: { break; } + case ModelProvider.Anthropic: { providerOptions = { baseURL: providerAuthPayload?.endpoint, }; break; } + case ModelProvider.Mistral: { break; }