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
afcab78c
Commit
afcab78c
authored
May 25, 2024
by
Timothy J. Baek
Browse files
fix: models
parent
3d0b3eb5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
9 deletions
+18
-9
backend/apps/web/routers/models.py
backend/apps/web/routers/models.py
+3
-3
src/lib/apis/models/index.ts
src/lib/apis/models/index.ts
+12
-3
src/lib/components/chat/Settings/General.svelte
src/lib/components/chat/Settings/General.svelte
+1
-1
src/routes/(app)/workspace/models/create/+page.svelte
src/routes/(app)/workspace/models/create/+page.svelte
+1
-1
src/routes/(app)/workspace/models/edit/+page.svelte
src/routes/(app)/workspace/models/edit/+page.svelte
+1
-1
No files found.
backend/apps/web/routers/models.py
View file @
afcab78c
...
@@ -53,7 +53,7 @@ async def add_new_model(
...
@@ -53,7 +53,7 @@ async def add_new_model(
############################
############################
@
router
.
get
(
"/
{id}
"
,
response_model
=
Optional
[
ModelModel
])
@
router
.
get
(
"/"
,
response_model
=
Optional
[
ModelModel
])
async
def
get_model_by_id
(
id
:
str
,
user
=
Depends
(
get_verified_user
)):
async
def
get_model_by_id
(
id
:
str
,
user
=
Depends
(
get_verified_user
)):
model
=
Models
.
get_model_by_id
(
id
)
model
=
Models
.
get_model_by_id
(
id
)
...
@@ -71,7 +71,7 @@ async def get_model_by_id(id: str, user=Depends(get_verified_user)):
...
@@ -71,7 +71,7 @@ async def get_model_by_id(id: str, user=Depends(get_verified_user)):
############################
############################
@
router
.
post
(
"/
{id}/
update"
,
response_model
=
Optional
[
ModelModel
])
@
router
.
post
(
"/update"
,
response_model
=
Optional
[
ModelModel
])
async
def
update_model_by_id
(
async
def
update_model_by_id
(
request
:
Request
,
id
:
str
,
form_data
:
ModelForm
,
user
=
Depends
(
get_admin_user
)
request
:
Request
,
id
:
str
,
form_data
:
ModelForm
,
user
=
Depends
(
get_admin_user
)
):
):
...
@@ -102,7 +102,7 @@ async def update_model_by_id(
...
@@ -102,7 +102,7 @@ async def update_model_by_id(
############################
############################
@
router
.
delete
(
"/
{id}/
delete"
,
response_model
=
bool
)
@
router
.
delete
(
"/delete"
,
response_model
=
bool
)
async
def
delete_model_by_id
(
id
:
str
,
user
=
Depends
(
get_admin_user
)):
async
def
delete_model_by_id
(
id
:
str
,
user
=
Depends
(
get_admin_user
)):
result
=
Models
.
delete_model_by_id
(
id
)
result
=
Models
.
delete_model_by_id
(
id
)
return
result
return
result
src/lib/apis/models/index.ts
View file @
afcab78c
...
@@ -63,7 +63,10 @@ export const getModelInfos = async (token: string = '') => {
...
@@ -63,7 +63,10 @@ export const getModelInfos = async (token: string = '') => {
export
const
getModelById
=
async
(
token
:
string
,
id
:
string
)
=>
{
export
const
getModelById
=
async
(
token
:
string
,
id
:
string
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/models/
${
id
}
`
,
{
const
url
=
new
URL
(
`
${
WEBUI_API_BASE_URL
}
/models`
);
url
.
searchParams
.
append
(
'
id
'
,
id
);
const
res
=
await
fetch
(
url
.
toString
(),
{
method
:
'
GET
'
,
method
:
'
GET
'
,
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/json
'
,
...
@@ -95,7 +98,10 @@ export const getModelById = async (token: string, id: string) => {
...
@@ -95,7 +98,10 @@ export const getModelById = async (token: string, id: string) => {
export
const
updateModelById
=
async
(
token
:
string
,
id
:
string
,
model
:
object
)
=>
{
export
const
updateModelById
=
async
(
token
:
string
,
id
:
string
,
model
:
object
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/models/
${
id
}
/update`
,
{
const
url
=
new
URL
(
`
${
WEBUI_API_BASE_URL
}
/models/update`
);
url
.
searchParams
.
append
(
'
id
'
,
id
);
const
res
=
await
fetch
(
url
.
toString
(),
{
method
:
'
POST
'
,
method
:
'
POST
'
,
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/json
'
,
...
@@ -128,7 +134,10 @@ export const updateModelById = async (token: string, id: string, model: object)
...
@@ -128,7 +134,10 @@ export const updateModelById = async (token: string, id: string, model: object)
export
const
deleteModelById
=
async
(
token
:
string
,
id
:
string
)
=>
{
export
const
deleteModelById
=
async
(
token
:
string
,
id
:
string
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/models/
${
id
}
/delete`
,
{
const
url
=
new
URL
(
`
${
WEBUI_API_BASE_URL
}
/models/delete`
);
url
.
searchParams
.
append
(
'
id
'
,
id
);
const
res
=
await
fetch
(
url
.
toString
(),
{
method
:
'
DELETE
'
,
method
:
'
DELETE
'
,
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/json
'
,
...
...
src/lib/components/chat/Settings/General.svelte
View file @
afcab78c
...
@@ -302,7 +302,7 @@
...
@@ -302,7 +302,7 @@
system: system !== '' ? system : undefined,
system: system !== '' ? system : undefined,
params: {
params: {
seed: (params.seed !== 0 ? params.seed : undefined) ?? undefined,
seed: (params.seed !== 0 ? params.seed : undefined) ?? undefined,
stop: params.stop
!== null
? params.stop.split(',').filter((e) => e) : undefined,
stop: params.stop ? params.stop.split(',').filter((e) => e) : undefined,
temperature: params.temperature !== '' ? params.temperature : undefined,
temperature: params.temperature !== '' ? params.temperature : undefined,
frequency_penalty:
frequency_penalty:
params.frequency_penalty !== '' ? params.frequency_penalty : undefined,
params.frequency_penalty !== '' ? params.frequency_penalty : undefined,
...
...
src/routes/(app)/workspace/models/create/+page.svelte
View file @
afcab78c
...
@@ -62,7 +62,7 @@
...
@@ -62,7 +62,7 @@
info.id = id;
info.id = id;
info.name = name;
info.name = name;
info.meta.capabilities = capabilities;
info.meta.capabilities = capabilities;
info.params.stop = params.stop
!== null
? params.stop.split(',').filter((s) => s.trim()) : null;
info.params.stop = params.stop ? params.stop.split(',').filter((s) => s.trim()) : null;
if ($models.find((m) => m.id === info.id)) {
if ($models.find((m) => m.id === info.id)) {
toast.error(
toast.error(
...
...
src/routes/(app)/workspace/models/edit/+page.svelte
View file @
afcab78c
...
@@ -63,7 +63,7 @@
...
@@ -63,7 +63,7 @@
info
.
id
=
id
;
info
.
id
=
id
;
info
.
name
=
name
;
info
.
name
=
name
;
info
.
meta
.
capabilities
=
capabilities
;
info
.
meta
.
capabilities
=
capabilities
;
info
.
params
.
stop
=
params
.
stop
!== null
? params.stop.split(',').filter((s) => s.trim()) : null;
info
.
params
.
stop
=
params
.
stop
?
params
.
stop
.
split
(
','
).
filter
((
s
)
=>
s
.
trim
())
:
null
;
const
res
=
await
updateModelById
(
localStorage
.
token
,
info
.
id
,
info
);
const
res
=
await
updateModelById
(
localStorage
.
token
,
info
.
id
,
info
);
...
...
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