Skip to content

Commit

Permalink
fix: prevent 400 when using runTools/runFunctions with Azure OpenAI A…
Browse files Browse the repository at this point in the history
…PI (#544)
  • Loading branch information
stainless-bot committed Nov 29, 2023
1 parent a048174 commit 735d9b8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/AbstractChatCompletionRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 735d9b8

Please sign in to comment.