From 735d9b86acdc067e1ee6ebe1ea50de2955431050 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Tue, 28 Nov 2023 18:33:57 -0500 Subject: [PATCH] fix: prevent 400 when using runTools/runFunctions with Azure OpenAI API (#544) --- src/lib/AbstractChatCompletionRunner.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/AbstractChatCompletionRunner.ts b/src/lib/AbstractChatCompletionRunner.ts index 60b1e5602..a485c487d 100644 --- a/src/lib/AbstractChatCompletionRunner.ts +++ b/src/lib/AbstractChatCompletionRunner.ts @@ -90,7 +90,11 @@ export abstract class AbstractChatCompletionRunner< } protected _addMessage(message: ChatCompletionMessageParam, emit = true) { + // @ts-expect-error this works around a bug in the Azure OpenAI API in which `content` is missing instead of null. + if (!('content' in message)) message.content = null; + this.messages.push(message); + if (emit) { this._emit('message', message); if ((isFunctionMessage(message) || isToolMessage(message)) && message.content) {