From 74359067d0e31c7a5ad80a72f01a219407e33ca7 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Wed, 13 Dec 2023 21:08:09 +0100 Subject: [PATCH] functionManager: don't return empty function array for openai openai doesn't accept empty function parameter, it was discovered after I removed the testing buildin function --- src/execution.ts | 2 +- src/funcitonManager.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/execution.ts b/src/execution.ts index 3b8e2fd..44e5710 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -246,7 +246,7 @@ async function executeFromQueue(channel: string) { ...config.chatCompletionParams, messages: OpenAImessages, // FIXME: don't use new instance of FunctionManager - functions: new FunctionManager().getFunctions(), + functions: new FunctionManager().getFunctionsForOpenAi(), }); logUsedTokens(answer, message, ++functionRanCounter); diff --git a/src/funcitonManager.ts b/src/funcitonManager.ts index 41e35c1..11b1bac 100644 --- a/src/funcitonManager.ts +++ b/src/funcitonManager.ts @@ -62,6 +62,11 @@ export default class FunctionManager { return rvalue; } + public getFunctionsForOpenAi(): ChatCompletionFunctions[] | undefined { + const rvalue = this.getFunctions(); + return rvalue.length > 0 ? rvalue : undefined; + } + public handleFunction(request: ChatCompletionFunctionCall): ChatCompletionMessageParam { // eslint-disable-next-line @typescript-eslint/no-explicit-any let parsedArguments: any;