Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
ee837915
Commit
ee837915
authored
Dec 24, 2023
by
Timothy J. Baek
Browse files
feat: return file_name for model name
parent
232401a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
backend/apps/web/routers/utils.py
backend/apps/web/routers/utils.py
+7
-6
src/lib/components/chat/SettingsModal.svelte
src/lib/components/chat/SettingsModal.svelte
+3
-0
No files found.
backend/apps/web/routers/utils.py
View file @
ee837915
...
...
@@ -42,7 +42,7 @@ def parse_huggingface_url(hf_url):
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
if
os
.
path
.
exists
(
file_path
):
...
...
@@ -79,7 +79,7 @@ async def download_file_stream(url, file_path, chunk_size=1024 * 1024):
res
=
{
"done"
:
done
,
"blob"
:
f
"sha256:
{
hashed
}
"
,
"name"
:
file
.
name
,
"name"
:
file
_
name
,
}
os
.
remove
(
file_path
)
...
...
@@ -93,14 +93,15 @@ async def download(
url
:
str
,
):
# url = "https://huggingface.co/TheBloke/stablelm-zephyr-3b-GGUF/resolve/main/stablelm-zephyr-3b.Q2_K.gguf"
model_fil
e
=
parse_huggingface_url
(
url
)
file_nam
e
=
parse_huggingface_url
(
url
)
if
model_fil
e
:
if
file_nam
e
:
os
.
makedirs
(
"./uploads"
,
exist_ok
=
True
)
file_path
=
os
.
path
.
join
(
"./uploads"
,
f
"
{
model_fil
e
}
"
)
file_path
=
os
.
path
.
join
(
"./uploads"
,
f
"
{
file_nam
e
}
"
)
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
:
return
None
...
...
src/lib/components/chat/SettingsModal.svelte
View file @
ee837915
...
...
@@ -276,6 +276,7 @@
const uploadModelHandler = async () => {
modelTransferring = true;
uploadProgress = 0;
let uploaded = false;
let fileResponse = null;
let name = '';
...
...
@@ -422,6 +423,8 @@
modelFileUrl = '';
modelInputFile = '';
modelTransferring = false;
uploadProgress = null;
models.set(await getModels());
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment