Revised the debug mode

This commit is contained in:
kinance
2023-04-08 13:05:32 +09:00
parent 0de94b11cd
commit c4c7350670
3 changed files with 4 additions and 5 deletions

View File

@@ -43,8 +43,7 @@ def chat_with_ai(
user_input, user_input,
full_message_history, full_message_history,
permanent_memory, permanent_memory,
token_limit, token_limit):
debug=False):
while True: while True:
try: try:
""" """

View File

@@ -40,7 +40,7 @@ def fix_and_parse_json(json_str: str, try_to_fix_with_gpt: bool = True):
if try_to_fix_with_gpt: if try_to_fix_with_gpt:
print(f"Warning: Failed to parse AI output, attempting to fix.\n If you see this warning frequently, it's likely that your prompt is confusing the AI. Try changing it up slightly.") print(f"Warning: Failed to parse AI output, attempting to fix.\n If you see this warning frequently, it's likely that your prompt is confusing the AI. Try changing it up slightly.")
# Now try to fix this up using the ai_functions # Now try to fix this up using the ai_functions
ai_fixed_json = fix_json(json_str, json_schema, False) ai_fixed_json = fix_json(json_str, json_schema)
if ai_fixed_json != "failed": if ai_fixed_json != "failed":
return json.loads(ai_fixed_json) return json.loads(ai_fixed_json)
else: else:
@@ -49,7 +49,7 @@ def fix_and_parse_json(json_str: str, try_to_fix_with_gpt: bool = True):
else: else:
raise e raise e
def fix_json(json_str: str, schema: str, debug=False) -> str: def fix_json(json_str: str, schema: str) -> str:
# Try to fix the JSON using gpt: # Try to fix the JSON using gpt:
function_string = "def fix_json(json_str: str, schema:str=None) -> str:" function_string = "def fix_json(json_str: str, schema:str=None) -> str:"
args = [f"'''{json_str}'''", f"'''{schema}'''"] args = [f"'''{json_str}'''", f"'''{schema}'''"]