(dialog, mode, json_file_path, dialog_id)
| 79 | return "" |
| 80 | |
| 81 | def save_json(dialog, mode, json_file_path, dialog_id) -> None: |
| 82 | with scheduler.lock: |
| 83 | with json_file_path.open("a") as f: |
| 84 | json.dump({"id": dialog_id, "dialog": dialog, "mode": mode, "datetime": datetime.now().isoformat()}, f, ensure_ascii=False) |
| 85 | f.write("\n") |
| 86 | |
| 87 | def convert_history(gradio_history: list[list], interpreter_history: list[dict]): |
| 88 | interpreter_history = [interpreter_history[0]] if interpreter_history and interpreter_history[0]["role"] == "system" else [] |