From 9eb644c9f691b745b37c620cbb0e55115a363b7d Mon Sep 17 00:00:00 2001 From: ikaros <327209194@qq.com> Date: Sun, 10 Nov 2024 12:40:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AText=20Gen=20WebUI?= =?UTF-8?q?=20=E6=97=A5=E5=BF=97=E8=B0=83=E7=94=A8=E9=94=99=E8=AF=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/gpt_model/text_generation_webui.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/gpt_model/text_generation_webui.py b/utils/gpt_model/text_generation_webui.py index 3ab64a6a..f8a8a50d 100644 --- a/utils/gpt_model/text_generation_webui.py +++ b/utils/gpt_model/text_generation_webui.py @@ -103,7 +103,7 @@ def get_resp(self, user_input): if response.status_code == 200: result = response.json()['results'][0]['history'] - # logging.info(json.dumps(result, indent=4)) + # logger.info(json.dumps(result, indent=4)) # print(result['visible'][-1][1]) resp_content = result['visible'][-1][1] @@ -113,7 +113,7 @@ def get_resp(self, user_input): # 统计字符数 total_chars = sum(len(item) for sublist in self.history['internal'] for item in sublist) total_chars += sum(len(item) for sublist in self.history['visible'] for item in sublist) - logging.info(f"total_chars={total_chars}") + logger.info(f"total_chars={total_chars}") # 如果大于限定最大历史数,就剔除第一个元素 if total_chars > self.history_max_len: self.history = self.remove_first_group(self.history) @@ -125,7 +125,7 @@ def get_resp(self, user_input): else: return None except Exception as e: - logging.error(traceback.format_exc()) + logger.error(traceback.format_exc()) return None else: try: @@ -200,11 +200,11 @@ def get_resp(self, user_input): # "grammar_string": "" } - logging.debug(data) + logger.debug(data) response = requests.post(url, headers=headers, json=data, verify=False) resp_json = response.json() - logging.debug(resp_json) + logger.debug(resp_json) resp_content = resp_json['choices'][0]['message']['content'] # 过滤多余的 \n @@ -226,7 +226,7 @@ def get_resp(self, user_input): return resp_content except Exception as e: - logging.error(traceback.format_exc()) + logger.error(traceback.format_exc()) return None @@ -279,5 +279,5 @@ def get_resp2(self, prompt): else: return None except Exception as e: - logging.error(e) + logger.error(e) return None