From cc28f3d4a183d1673d15e806da1d7b3787348d7c Mon Sep 17 00:00:00 2001 From: Paillat Date: Wed, 23 Aug 2023 15:39:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(openaicaller.py):=20fix=20er?= =?UTF-8?q?ror=20in=20generate=5Fresponse=20method=20where=20error=5Fcall?= =?UTF-8?q?=20argument=20is=20not=20properly=20handled=20=E2=9C=A8=20feat(?= =?UTF-8?q?openaicaller.py):=20add=20default=20value=20for=20error=5Fcall?= =?UTF-8?q?=20argument=20in=20generate=5Fresponse=20method=20to=20prevent?= =?UTF-8?q?=20potential=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/openaicaller.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/openaicaller.py b/src/utils/openaicaller.py index 2006f61..416fdb0 100644 --- a/src/utils/openaicaller.py +++ b/src/utils/openaicaller.py @@ -83,14 +83,20 @@ class openai_caller: # async def generate_response(self, error_call=None, **kwargs): async def generate_response(*args, **kwargs): self = args[0] - if args.get("error_call", None) != None: - error_call = args[1] + if len(args) > 1: + error_call = args[1] or nothing else: async def nothing(x): return x error_call = nothing + if error_call == None: + + async def nothing(x): + return x + + error_call = nothing if kwargs.get("model", "") in chat_models: return await self.chat_generate(error_call, **kwargs) elif kwargs.get("engine", "") in text_models: