From 924f1caa390c1bccc0adc9b98274d4e8c47aae74 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Wed, 19 Apr 2023 13:27:04 -0600 Subject: [PATCH] fix wrong func. --- matrix_gpt/bot/chat_functions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/matrix_gpt/bot/chat_functions.py b/matrix_gpt/bot/chat_functions.py index 83714dc..c75350c 100644 --- a/matrix_gpt/bot/chat_functions.py +++ b/matrix_gpt/bot/chat_functions.py @@ -191,8 +191,10 @@ async def process_chat( # I don't think the OpenAI py api has a built-in timeout @stopit.threading_timeoutable(default=(None, None)) async def generate(): - return await loop.run_in_executor(None, functools.partial(openai_obj.ChatCompletion.create, model=openai_model, messages=messages, temperature=openai_temperature, timeout=20)) - # r = openai_obj.ChatCompletion.create(model=openai_model, messages=messages, temperature=openai_temperature, timeout=20) + if openai_model in ['gpt-3', 'gpt-4']: + return await loop.run_in_executor(None, functools.partial(openai_obj.ChatCompletion.create, model=openai_model, messages=messages, temperature=openai_temperature, timeout=20)) + elif openai_model in ['text-davinci-003', 'davinci-instruct-beta', 'text-davinci-001', 'text-davinci-002', 'text-curie-001', 'text-babbage-001']: + return await loop.run_in_executor(None, functools.partial(openai_obj.Completion.create, model=openai_model, temperature=openai_temperature, timeout=20)) response = None for i in range(openai_retries):