upgrade gradio to 4.21.0

Former-commit-id: 63eecbeb967d849e1d03d8d03fb6421c0ee89257
This commit is contained in:
hiyouga
2024-03-30 20:37:08 +08:00
parent fbd0584391
commit b0efebf853
18 changed files with 167 additions and 159 deletions

View File

@@ -19,26 +19,26 @@ if is_matplotlib_available():
import matplotlib.pyplot as plt
def update_process_bar(callback: "LogCallback") -> Dict[str, Any]:
def update_process_bar(callback: "LogCallback") -> "gr.Slider":
if not callback.max_steps:
return gr.update(visible=False)
return gr.Slider(visible=False)
percentage = round(100 * callback.cur_steps / callback.max_steps, 0) if callback.max_steps != 0 else 100.0
label = "Running {:d}/{:d}: {} < {}".format(
callback.cur_steps, callback.max_steps, callback.elapsed_time, callback.remaining_time
)
return gr.update(label=label, value=percentage, visible=True)
return gr.Slider(label=label, value=percentage, visible=True)
def get_time() -> str:
return datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
return datetime.now().strftime(r"%Y-%m-%d-%H-%M-%S")
def can_quantize(finetuning_type: str) -> Dict[str, Any]:
def can_quantize(finetuning_type: str) -> "gr.Dropdown":
if finetuning_type != "lora":
return gr.update(value="None", interactive=False)
return gr.Dropdown(value="None", interactive=False)
else:
return gr.update(interactive=True)
return gr.Dropdown(interactive=True)
def check_json_schema(text: str, lang: str) -> None:
@@ -48,8 +48,8 @@ def check_json_schema(text: str, lang: str) -> None:
assert isinstance(tools, list)
for tool in tools:
if "name" not in tool:
raise ValueError("Name not found.")
except ValueError:
raise NotImplementedError("Name not found.")
except NotImplementedError:
gr.Warning(ALERTS["err_tool_name"][lang])
except Exception:
gr.Warning(ALERTS["err_json_schema"][lang])