From 068e7a834f712cb3af0fce6f1fa6c70dc443f40a Mon Sep 17 00:00:00 2001 From: nai-degen Date: Mon, 4 Mar 2024 21:22:43 -0600 Subject: [PATCH] fixes AWS legacy models for non-streaming requests --- src/proxy/aws.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/proxy/aws.ts b/src/proxy/aws.ts index d6425a3..1fcb1d9 100644 --- a/src/proxy/aws.ts +++ b/src/proxy/aws.ts @@ -16,7 +16,10 @@ import { ProxyResHandlerWithBody, createOnProxyResHandler, } from "./middleware/response"; -import { handleCompatibilityRequest, transformAnthropicChatResponseToAnthropicText } from "./anthropic"; +import { + handleCompatibilityRequest, + transformAnthropicChatResponseToAnthropicText, +} from "./anthropic"; const LATEST_AWS_V2_MINOR_VERSION = "1"; const CLAUDE_3_COMPAT_MODEL = "anthropic.claude-3-sonnet-20240229-v1:0"; @@ -79,8 +82,11 @@ const awsResponseHandler: ProxyResHandlerWithBody = async ( body = transformAwsTextResponseToOpenAI(body, req); } - if (req.inboundApi === "anthropic-text") { - req.log.info("Transforming Text AWS Claude response to Chat format"); + if ( + req.inboundApi === "anthropic-text" && + req.outboundApi === "anthropic-chat" + ) { + req.log.info("Transforming AWS Claude chat response to Text format"); body = transformAnthropicChatResponseToAnthropicText(body, req); }