forked from open-webui/open-webui
fix: ollama gguf upload
This commit is contained in:
parent
af4caec4f5
commit
bc80f1438c
3 changed files with 26 additions and 12 deletions
|
@ -963,6 +963,9 @@ async def download_file_stream(
|
||||||
|
|
||||||
done = current_size == total_size
|
done = current_size == total_size
|
||||||
progress = round((current_size / total_size) * 100, 2)
|
progress = round((current_size / total_size) * 100, 2)
|
||||||
|
|
||||||
|
print(progress)
|
||||||
|
|
||||||
yield f'data: {{"progress": {progress}, "completed": {current_size}, "total": {total_size}}}\n\n'
|
yield f'data: {{"progress": {progress}, "completed": {current_size}, "total": {total_size}}}\n\n'
|
||||||
|
|
||||||
if done:
|
if done:
|
||||||
|
@ -986,6 +989,11 @@ async def download_file_stream(
|
||||||
raise "Ollama: Could not create blob, Please try again."
|
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"
|
# 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")
|
||||||
@app.post("/models/download/{url_idx}")
|
@app.post("/models/download/{url_idx}")
|
||||||
|
@ -1002,9 +1010,8 @@ async def download_model(
|
||||||
|
|
||||||
if file_name:
|
if file_name:
|
||||||
file_path = f"{UPLOAD_DIR}/{file_name}"
|
file_path = f"{UPLOAD_DIR}/{file_name}"
|
||||||
|
|
||||||
return StreamingResponse(
|
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:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -402,6 +402,8 @@ export const downloadModel = async (
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
Authorization: `Bearer ${token}`
|
Authorization: `Bearer ${token}`
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
|
|
@ -196,7 +196,7 @@
|
||||||
const file = modelInputFile ? modelInputFile[0] : null;
|
const file = modelInputFile ? modelInputFile[0] : null;
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
fileResponse = uploadModel(localStorage.token, file, selectedOllamaUrlIdx).catch(
|
fileResponse = await uploadModel(localStorage.token, file, selectedOllamaUrlIdx).catch(
|
||||||
(error) => {
|
(error) => {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
return null;
|
return null;
|
||||||
|
@ -204,12 +204,14 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileResponse = downloadModel(localStorage.token, modelFileUrl, selectedOllamaUrlIdx).catch(
|
fileResponse = await downloadModel(
|
||||||
(error) => {
|
localStorage.token,
|
||||||
|
modelFileUrl,
|
||||||
|
selectedOllamaUrlIdx
|
||||||
|
).catch((error) => {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
return null;
|
return null;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileResponse && fileResponse.ok) {
|
if (fileResponse && fileResponse.ok) {
|
||||||
|
@ -313,7 +315,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
modelFileUrl = '';
|
modelFileUrl = '';
|
||||||
|
|
||||||
|
if (modelUploadInputElement) {
|
||||||
modelUploadInputElement.value = '';
|
modelUploadInputElement.value = '';
|
||||||
|
}
|
||||||
modelInputFile = null;
|
modelInputFile = null;
|
||||||
modelTransferring = false;
|
modelTransferring = false;
|
||||||
uploadProgress = null;
|
uploadProgress = null;
|
||||||
|
@ -741,7 +746,7 @@
|
||||||
|
|
||||||
{#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
|
{#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')}
|
||||||
<button
|
<button
|
||||||
class="px-3 text-gray-100 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-800 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"
|
type="submit"
|
||||||
disabled={modelTransferring}
|
disabled={modelTransferring}
|
||||||
>
|
>
|
||||||
|
@ -796,7 +801,7 @@
|
||||||
<div class=" my-2.5 text-sm font-medium">{$i18n.t('Modelfile Content')}</div>
|
<div class=" my-2.5 text-sm font-medium">{$i18n.t('Modelfile Content')}</div>
|
||||||
<textarea
|
<textarea
|
||||||
bind:value={modelFileContent}
|
bind:value={modelFileContent}
|
||||||
class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
|
class="w-full rounded-lg py-2 px-4 text-sm bg-gray-100 dark:text-gray-100 dark:bg-gray-850 outline-none resize-none"
|
||||||
rows="6"
|
rows="6"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue