forked from open-webui/open-webui
feat: return file_name for model name
This commit is contained in:
parent
232401a042
commit
ee83791596
2 changed files with 10 additions and 6 deletions
|
@ -42,7 +42,7 @@ def parse_huggingface_url(hf_url):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
async def download_file_stream(url, file_path, chunk_size=1024 * 1024):
|
async def download_file_stream(url, file_path, file_name, chunk_size=1024 * 1024):
|
||||||
done = False
|
done = False
|
||||||
|
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
|
@ -79,7 +79,7 @@ async def download_file_stream(url, file_path, chunk_size=1024 * 1024):
|
||||||
res = {
|
res = {
|
||||||
"done": done,
|
"done": done,
|
||||||
"blob": f"sha256:{hashed}",
|
"blob": f"sha256:{hashed}",
|
||||||
"name": file.name,
|
"name": file_name,
|
||||||
}
|
}
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
||||||
|
@ -93,14 +93,15 @@ async def download(
|
||||||
url: str,
|
url: str,
|
||||||
):
|
):
|
||||||
# url = "https://huggingface.co/TheBloke/stablelm-zephyr-3b-GGUF/resolve/main/stablelm-zephyr-3b.Q2_K.gguf"
|
# url = "https://huggingface.co/TheBloke/stablelm-zephyr-3b-GGUF/resolve/main/stablelm-zephyr-3b.Q2_K.gguf"
|
||||||
model_file = parse_huggingface_url(url)
|
file_name = parse_huggingface_url(url)
|
||||||
|
|
||||||
if model_file:
|
if file_name:
|
||||||
os.makedirs("./uploads", exist_ok=True)
|
os.makedirs("./uploads", exist_ok=True)
|
||||||
file_path = os.path.join("./uploads", f"{model_file}")
|
file_path = os.path.join("./uploads", f"{file_name}")
|
||||||
|
|
||||||
return StreamingResponse(
|
return StreamingResponse(
|
||||||
download_file_stream(url, file_path), media_type="text/event-stream"
|
download_file_stream(url, file_path, file_name),
|
||||||
|
media_type="text/event-stream",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -276,6 +276,7 @@
|
||||||
|
|
||||||
const uploadModelHandler = async () => {
|
const uploadModelHandler = async () => {
|
||||||
modelTransferring = true;
|
modelTransferring = true;
|
||||||
|
uploadProgress = 0;
|
||||||
let uploaded = false;
|
let uploaded = false;
|
||||||
let fileResponse = null;
|
let fileResponse = null;
|
||||||
let name = '';
|
let name = '';
|
||||||
|
@ -422,6 +423,8 @@
|
||||||
modelFileUrl = '';
|
modelFileUrl = '';
|
||||||
modelInputFile = '';
|
modelInputFile = '';
|
||||||
modelTransferring = false;
|
modelTransferring = false;
|
||||||
|
uploadProgress = null;
|
||||||
|
|
||||||
models.set(await getModels());
|
models.set(await getModels());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue