fix web ui demo

This commit is contained in:
hiyouga 2023-11-16 17:12:23 +08:00
parent c4facc03af
commit 1c80e9a09e
3 changed files with 11 additions and 4 deletions

View File

@ -7,4 +7,4 @@ from llmtuner.train import export_model, run_exp
from llmtuner.webui import create_ui, create_web_demo
__version__ = "0.3.0"
__version__ = "0.3.1"

View File

@ -29,8 +29,14 @@ class WebChatModel(ChatModel):
if not lazy_init: # read arguments from command line
super().__init__()
if demo_mode: # load openchat 3.5 by default
super().__init__(dict(model_name_or_path="openchat/openchat_3.5", template="openchat"))
if demo_mode: # load config.json by default
import json
try:
with open("demo_config.json", "r", encoding="utf-8") as f:
args = json.load(f)
except:
raise ValueError("Cannot find `demo_config.json` at current directory.")
super().__init__(args)
@property
def loaded(self) -> bool:

View File

@ -13,6 +13,7 @@ from llmtuner.webui.utils import get_time
class Engine:
def __init__(self, demo_mode: Optional[bool] = False, pure_chat: Optional[bool] = False) -> None:
self.demo_mode = demo_mode
self.pure_chat = pure_chat
self.manager = Manager()
self.runner = Runner(self.manager, demo_mode=demo_mode)
@ -22,7 +23,7 @@ class Engine:
return {self.manager.get_elem_by_name(k): gr.update(**v) for k, v in resume_dict.items()}
def resume(self) -> Generator[Dict[Component, Dict[str, Any]], None, None]:
user_config = load_config()
user_config = load_config() if not self.demo_mode else {}
lang = user_config.get("lang", None) or "en"
init_dict = {