From ce104d15eefb2df21b8fcd1ae5c4703a7daeefc1 Mon Sep 17 00:00:00 2001 From: Rock Chin Date: Mon, 12 Dec 2022 17:21:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=AA=E5=90=91=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9C=80=E5=A4=A7=E5=9B=9E=E5=90=88=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/openai/session.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/openai/session.py b/pkg/openai/session.py index 1ec76f14..b1b50f15 100644 --- a/pkg/openai/session.py +++ b/pkg/openai/session.py @@ -100,12 +100,13 @@ class Session: def append(self, text: str) -> str: self.last_interact_timestamp = int(time.time()) - max_length = config.prompt_submit_length if config.prompt_submit_length is not None else 1024 + max_rounds = config.prompt_submit_round_amount if hasattr(config, 'prompt_submit_round_amount') else 7 + max_length = config.prompt_submit_length if hasattr(config, "prompt_submit_length") else 1024 # 向API请求补全 response = pkg.openai.manager.get_inst().request_completion(self.cut_out(self.prompt + self.user_name + ':' + text + '\n' + self.bot_name + ':', - 7, max_length), self.user_name + ':') + max_rounds, max_length), self.user_name + ':') self.prompt += self.user_name + ':' + text + '\n' + self.bot_name + ':' # print(response)