[webui] upgrade webui and fix api (#8460)

This commit is contained in:
Yaowei Zheng
2025-06-25 21:59:58 +08:00
committed by GitHub
parent f276b9a963
commit 4407231a3b
9 changed files with 109 additions and 27 deletions

View File

@@ -50,7 +50,7 @@ class LoggerHandler(logging.Handler):
def _write_log(self, log_entry: str) -> None:
with open(self.running_log, "a", encoding="utf-8") as f:
f.write(log_entry + "\n\n")
f.write(log_entry + "\n")
def emit(self, record) -> None:
if record.name == "httpx":

View File

@@ -182,8 +182,22 @@ def get_logits_processor() -> "LogitsProcessorList":
return logits_processor
def get_current_memory() -> tuple[int, int]:
r"""Get the available and total memory for the current device (in Bytes)."""
if is_torch_xpu_available():
return torch.xpu.mem_get_info()
elif is_torch_npu_available():
return torch.npu.mem_get_info()
elif is_torch_mps_available():
return torch.mps.current_allocated_memory(), torch.mps.recommended_max_memory()
elif is_torch_cuda_available():
return torch.cuda.mem_get_info()
else:
return 0, -1
def get_peak_memory() -> tuple[int, int]:
r"""Get the peak memory usage for the current device (in Bytes)."""
r"""Get the peak memory usage (allocated, reserved) for the current device (in Bytes)."""
if is_torch_xpu_available():
return torch.xpu.max_memory_allocated(), torch.xpu.max_memory_reserved()
elif is_torch_npu_available():
@@ -193,7 +207,7 @@ def get_peak_memory() -> tuple[int, int]:
elif is_torch_cuda_available():
return torch.cuda.max_memory_allocated(), torch.cuda.max_memory_reserved()
else:
return 0, 0
return 0, -1
def has_tokenized_data(path: "os.PathLike") -> bool: