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
bc80f143
Commit
bc80f143
authored
Mar 22, 2024
by
Timothy J. Baek
Browse files
fix: ollama gguf upload
parent
af4caec4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
backend/apps/ollama/main.py
backend/apps/ollama/main.py
+9
-2
src/lib/apis/ollama/index.ts
src/lib/apis/ollama/index.ts
+2
-0
src/lib/components/chat/Settings/Models.svelte
src/lib/components/chat/Settings/Models.svelte
+15
-10
No files found.
backend/apps/ollama/main.py
View file @
bc80f143
...
...
@@ -963,6 +963,9 @@ async def download_file_stream(
done
=
current_size
==
total_size
progress
=
round
((
current_size
/
total_size
)
*
100
,
2
)
print
(
progress
)
yield
f
'data: {{"progress":
{
progress
}
, "completed":
{
current_size
}
, "total":
{
total_size
}
}}
\n\n
'
if
done
:
...
...
@@ -986,6 +989,11 @@ async def download_file_stream(
raise
"Ollama: Could not create blob, Please try again."
# def number_generator():
# for i in range(1, 101):
# yield f"data: {i}\n"
# url = "https://huggingface.co/TheBloke/stablelm-zephyr-3b-GGUF/resolve/main/stablelm-zephyr-3b.Q2_K.gguf"
@
app
.
post
(
"/models/download"
)
@
app
.
post
(
"/models/download/{url_idx}"
)
...
...
@@ -1002,9 +1010,8 @@ async def download_model(
if
file_name
:
file_path
=
f
"
{
UPLOAD_DIR
}
/
{
file_name
}
"
return
StreamingResponse
(
download_file_stream
(
url
,
form_data
.
url
,
file_path
,
file_name
)
download_file_stream
(
url
,
form_data
.
url
,
file_path
,
file_name
)
,
)
else
:
return
None
...
...
src/lib/apis/ollama/index.ts
View file @
bc80f143
...
...
@@ -402,6 +402,8 @@ export const downloadModel = async (
{
method
:
'
POST
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
token
}
`
},
body
:
JSON
.
stringify
({
...
...
src/lib/components/chat/Settings/Models.svelte
View file @
bc80f143
...
...
@@ -196,7 +196,7 @@
const file = modelInputFile ? modelInputFile[0] : null;
if (file) {
fileResponse = uploadModel(localStorage.token, file, selectedOllamaUrlIdx).catch(
fileResponse =
await
uploadModel(localStorage.token, file, selectedOllamaUrlIdx).catch(
(error) => {
toast.error(error);
return null;
...
...
@@ -204,12 +204,14 @@
);
}
} else {
fileResponse = downloadModel(localStorage.token, modelFileUrl, selectedOllamaUrlIdx).catch(
(error) => {
fileResponse = await downloadModel(
localStorage.token,
modelFileUrl,
selectedOllamaUrlIdx
).catch((error) => {
toast.error(error);
return null;
}
);
});
}
if (fileResponse && fileResponse.ok) {
...
...
@@ -313,7 +315,10 @@
}
modelFileUrl = '';
if (modelUploadInputElement) {
modelUploadInputElement.value = '';
}
modelInputFile = null;
modelTransferring = false;
uploadProgress = null;
...
...
@@ -741,7 +746,7 @@
{#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
<button
class="px-
3
text-gray-
1
00
bg-emerald-600 hover:bg-emerald-700
disabled:bg-gray-700 disabled:cursor-not-allowed
rounded
transition"
class="px-
2.5 bg-gray-100 hover:bg-gray-200
text-gray-
8
00
dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg
disabled:bg-gray-700 disabled:cursor-not-allowed transition"
type="submit"
disabled={modelTransferring}
>
...
...
@@ -796,7 +801,7 @@
<div class=" my-2.5 text-sm font-medium">{$i18n.t('Modelfile Content')}</div>
<textarea
bind:value={modelFileContent}
class="w-full rounded py-2 px-4 text-sm dark:text-gray-
3
00 dark:bg-gray-8
0
0 outline-none resize-none"
class="w-full rounded
-lg
py-2 px-4 text-sm
bg-gray-100
dark:text-gray-
1
00 dark:bg-gray-8
5
0 outline-none resize-none"
rows="6"
/>
</div>
...
...
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