| 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 [] |
| 89 | if not gradio_history: |
| 90 | return interpreter_history |
| 91 | for item in gradio_history: |
| 92 | if item[0] is not None: |
| 93 | interpreter_history.append({"role": "user", "content": item[0]}) |
| 94 | if item[1] is not None: |
| 95 | interpreter_history.append({"role": "assistant", "content": item[1]}) |
| 96 | return interpreter_history |
| 97 | |
| 98 | def update_uuid(dialog_info): |
| 99 | new_uuid = str(uuid4()) |