fixes regression in anthropic text > anthropic chat api translation

This commit is contained in:
nai-degen 2024-03-08 21:16:25 -06:00
parent fab404b232
commit cab346787c
2 changed files with 5 additions and 2 deletions

View File

@ -81,7 +81,8 @@ export const handleStreamedResponse: RawResponseBodyHandler = async (
// Transformer converts server-sent events from one vendor's API message
// format to another.
const transformer = new SSEMessageTransformer({
inputFormat: req.outboundApi,
inputFormat: req.outboundApi, // The format of the upstream service's events
outputFormat: req.inboundApi, // The format the client requested
inputApiVersion: String(req.headers["anthropic-version"]),
logger: req.log,
requestId: String(req.id),

View File

@ -20,6 +20,7 @@ type SSEMessageTransformerOptions = TransformOptions & {
requestId: string;
inputFormat: APIFormat;
inputApiVersion?: string;
outputFormat?: APIFormat;
logger: typeof logger;
};
@ -47,7 +48,8 @@ export class SSEMessageTransformer extends Transform {
this.msgCount = 0;
this.transformFn = getTransformer(
options.inputFormat,
options.inputApiVersion
options.inputApiVersion,
options.outputFormat
);
this.inputFormat = options.inputFormat;
this.fallbackId = options.requestId;