Skip to content

Commit

Permalink
[Fix] Fix persist_file in webui (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanqiNO1 authored Feb 18, 2024
1 parent 08a1c08 commit 65a070e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webui/modules/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import hashlib
import html
import json
import shutil
from datetime import datetime
from pathlib import Path

Expand Down Expand Up @@ -29,7 +30,7 @@ def persist_file(path):
new_path.mkdir(parents=True, exist_ok=True)
new_path = new_path / filename
if not new_path.exists():
path.rename(new_path)
shutil.move(path, new_path)
return new_path


Expand Down Expand Up @@ -117,6 +118,7 @@ def generate_chat_reply_wrapper(text, state, file=None, regenerate=False):
for i, history in enumerate(generate_chat_reply(text, state, file, regenerate, loading_message=True)):
yield chat_html_wrapper(history), history


def upload_file(file, uploaded, history):
if not file:
return gr.update()
Expand All @@ -130,6 +132,7 @@ def upload_file(file, uploaded, history):
output['visible'] = output['visible'] + [[visible, '']]
return uploaded, chat_html_wrapper(output)


def redraw_html(history):
return chat_html_wrapper(history)

Expand Down Expand Up @@ -211,6 +214,7 @@ def load_latest_history():

return history


def recover_message(data):
from . import message_schema as msg

Expand All @@ -224,6 +228,7 @@ def recover_message(data):
else:
return data


def load_history(unique_id):
p = get_history_file_path(unique_id)

Expand Down

0 comments on commit 65a070e

Please sign in to comment.