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
fbdac832
"examples/git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "fbffbc7c70566dd05156d7e808048296f0b92b38"
Commit
fbdac832
authored
Mar 05, 2024
by
Timothy J. Baek
Browse files
feat: multiple ollama model management
parent
8181d98e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
348 additions
and
303 deletions
+348
-303
backend/apps/ollama/main.py
backend/apps/ollama/main.py
+6
-2
src/lib/apis/ollama/index.ts
src/lib/apis/ollama/index.ts
+17
-14
src/lib/components/chat/Settings/Models.svelte
src/lib/components/chat/Settings/Models.svelte
+325
-287
No files found.
backend/apps/ollama/main.py
View file @
fbdac832
...
...
@@ -207,9 +207,12 @@ async def pull_model(
form_data
:
ModelNameForm
,
url_idx
:
int
=
0
,
user
=
Depends
(
get_admin_user
)
):
url
=
app
.
state
.
OLLAMA_BASE_URLS
[
url_idx
]
print
(
url
)
r
=
None
def
get_request
(
url
):
def
get_request
():
nonlocal
url
nonlocal
r
try
:
...
...
@@ -235,7 +238,7 @@ async def pull_model(
raise
e
try
:
return
await
run_in_threadpool
(
get_request
(
url
)
)
return
await
run_in_threadpool
(
get_request
)
except
Exception
as
e
:
print
(
e
)
error_detail
=
"Open WebUI: Server Connection Error"
...
...
@@ -454,6 +457,7 @@ async def delete_model(
)
url
=
app
.
state
.
OLLAMA_BASE_URLS
[
url_idx
]
print
(
url
)
try
:
r
=
requests
.
request
(
...
...
src/lib/apis/ollama/index.ts
View file @
fbdac832
...
...
@@ -318,20 +318,23 @@ export const createModel = async (token: string, tagName: string, content: strin
return
res
;
};
export
const
deleteModel
=
async
(
token
:
string
,
tagName
:
string
)
=>
{
export
const
deleteModel
=
async
(
token
:
string
,
tagName
:
string
,
urlIdx
:
string
|
null
=
null
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
OLLAMA_API_BASE_URL
}
/api/delete`
,
{
method
:
'
DELETE
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
token
}
`
},
body
:
JSON
.
stringify
({
name
:
tagName
})
})
const
res
=
await
fetch
(
`
${
OLLAMA_API_BASE_URL
}
/api/delete
${
urlIdx
!==
null
?
`/
${
urlIdx
}
`
:
''
}
`
,
{
method
:
'
DELETE
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
token
}
`
},
body
:
JSON
.
stringify
({
name
:
tagName
})
}
)
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
...
...
@@ -358,10 +361,10 @@ export const deleteModel = async (token: string, tagName: string) => {
return
res
;
};
export
const
pullModel
=
async
(
token
:
string
,
tagName
:
string
)
=>
{
export
const
pullModel
=
async
(
token
:
string
,
tagName
:
string
,
urlIdx
:
string
|
null
=
null
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
OLLAMA_API_BASE_URL
}
/api/pull`
,
{
const
res
=
await
fetch
(
`
${
OLLAMA_API_BASE_URL
}
/api/pull
${
urlIdx
!==
null
?
`/
${
urlIdx
}
`
:
''
}
`
,
{
method
:
'
POST
'
,
headers
:
{
Accept
:
'
application/json
'
,
...
...
src/lib/components/chat/Settings/Models.svelte
View file @
fbdac832
This diff is collapsed.
Click to expand it.
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