From e5b756ecfe23beac03771b8ec404f0a313572794 Mon Sep 17 00:00:00 2001 From: matatonic <73265741+matatonic@users.noreply.github.com> Date: Tue, 30 May 2023 21:07:40 -0400 Subject: [PATCH] Fixes #2331, IndexError: string index out of range (#2383) --- extensions/openai/script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/openai/script.py b/extensions/openai/script.py index 1914dcf4..039c4699 100644 --- a/extensions/openai/script.py +++ b/extensions/openai/script.py @@ -346,7 +346,7 @@ class Handler(BaseHTTPRequestHandler): # can't really truncate the system messages system_msg = '\n'.join(system_msgs) - if system_msg[-1] != '\n': + if system_msg and system_msg[-1] != '\n': system_msg = system_msg + '\n' system_token_count = len(encode(system_msg)[0])