Skip to content

Commit

Permalink
Merge pull request #1054 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
修复:Text Gen WebUI 日志调用错误bug
  • Loading branch information
Ikaros-521 authored Nov 10, 2024
2 parents 94bee34 + 9eb644c commit ffa5f08
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions utils/gpt_model/text_generation_webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -279,5 +279,5 @@ def get_resp2(self, prompt):
else:
return None
except Exception as e:
logging.error(e)
logger.error(e)
return None

0 comments on commit ffa5f08

Please sign in to comment.