From 81a3ae17469263ef21649c4e417e23182dceccf1 Mon Sep 17 00:00:00 2001 From: nai-degen Date: Thu, 19 Sep 2024 00:50:17 -0500 Subject: [PATCH] maybe fixes missing anthropic version header in some cases --- src/proxy/middleware/request/mutators/add-key.ts | 1 + src/shared/api-schemas/anthropic.ts | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/proxy/middleware/request/mutators/add-key.ts b/src/proxy/middleware/request/mutators/add-key.ts index db2a3af..d966322 100644 --- a/src/proxy/middleware/request/mutators/add-key.ts +++ b/src/proxy/middleware/request/mutators/add-key.ts @@ -70,6 +70,7 @@ export const addKey: ProxyReqMutator = (manager) => { switch (assignedKey.service) { case "anthropic": manager.setHeader("X-API-Key", assignedKey.key); + manager.setHeader("anthropic-version", "2023-06-01"); break; case "openai": const key: OpenAIKey = assignedKey as OpenAIKey; diff --git a/src/shared/api-schemas/anthropic.ts b/src/shared/api-schemas/anthropic.ts index aa077f3..bce5730 100644 --- a/src/shared/api-schemas/anthropic.ts +++ b/src/shared/api-schemas/anthropic.ts @@ -110,8 +110,6 @@ export const transformOpenAIToAnthropicChat: APIFormatTransformer< throw result.error; } - req.headers["anthropic-version"] = "2023-06-01"; - const { messages, ...rest } = result.data; const { messages: newMessages, system } = openAIMessagesToClaudeChatPrompt(messages); @@ -146,8 +144,6 @@ export const transformOpenAIToAnthropicText: APIFormatTransformer< throw result.error; } - req.headers["anthropic-version"] = "2023-06-01"; - const { messages, ...rest } = result.data; const prompt = openAIMessagesToClaudeTextPrompt(messages); @@ -192,8 +188,6 @@ export const transformAnthropicTextToAnthropicChat: APIFormatTransformer< throw result.error; } - req.headers["anthropic-version"] = "2023-06-01"; - const { model, max_tokens_to_sample, prompt, ...rest } = result.data; validateAnthropicTextPrompt(prompt);