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
82114c45
Commit
82114c45
authored
Jan 06, 2024
by
Timothy J. Baek
Browse files
fix: allow command named create
parent
c55c8728
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
13 deletions
+11
-13
backend/apps/web/routers/prompts.py
backend/apps/web/routers/prompts.py
+8
-10
src/lib/apis/prompts/index.ts
src/lib/apis/prompts/index.ts
+3
-3
No files found.
backend/apps/web/routers/prompts.py
View file @
82114c45
...
...
@@ -29,8 +29,7 @@ async def get_prompts(user=Depends(get_current_user)):
@
router
.
post
(
"/create"
,
response_model
=
Optional
[
PromptModel
])
async
def
create_new_prompt
(
form_data
:
PromptForm
,
user
=
Depends
(
get_current_user
)):
async
def
create_new_prompt
(
form_data
:
PromptForm
,
user
=
Depends
(
get_current_user
)):
if
user
.
role
!=
"admin"
:
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
...
...
@@ -60,7 +59,7 @@ async def create_new_prompt(form_data: PromptForm,
############################
@
router
.
get
(
"/{command}"
,
response_model
=
Optional
[
PromptModel
])
@
router
.
get
(
"/
command/
{command}"
,
response_model
=
Optional
[
PromptModel
])
async
def
get_prompt_by_command
(
command
:
str
,
user
=
Depends
(
get_current_user
)):
prompt
=
Prompts
.
get_prompt_by_command
(
f
"/
{
command
}
"
)
...
...
@@ -78,10 +77,10 @@ async def get_prompt_by_command(command: str, user=Depends(get_current_user)):
############################
@
router
.
post
(
"/{command}/update"
,
response_model
=
Optional
[
PromptModel
])
async
def
update_prompt_by_command
(
command
:
str
,
form_data
:
PromptForm
,
user
=
Depends
(
get_current_user
)
):
@
router
.
post
(
"/
command/
{command}/update"
,
response_model
=
Optional
[
PromptModel
])
async
def
update_prompt_by_command
(
command
:
str
,
form_data
:
PromptForm
,
user
=
Depends
(
get_current_user
)
):
if
user
.
role
!=
"admin"
:
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
...
...
@@ -103,9 +102,8 @@ async def update_prompt_by_command(command: str,
############################
@
router
.
delete
(
"/{command}/delete"
,
response_model
=
bool
)
async
def
delete_prompt_by_command
(
command
:
str
,
user
=
Depends
(
get_current_user
)):
@
router
.
delete
(
"/command/{command}/delete"
,
response_model
=
bool
)
async
def
delete_prompt_by_command
(
command
:
str
,
user
=
Depends
(
get_current_user
)):
if
user
.
role
!=
"admin"
:
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
...
...
src/lib/apis/prompts/index.ts
View file @
82114c45
...
...
@@ -72,7 +72,7 @@ export const getPrompts = async (token: string = '') => {
export
const
getPromptByCommand
=
async
(
token
:
string
,
command
:
string
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/prompts/
${
command
}
`
,
{
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/prompts/
command/
${
command
}
`
,
{
method
:
'
GET
'
,
headers
:
{
Accept
:
'
application/json
'
,
...
...
@@ -109,7 +109,7 @@ export const updatePromptByCommand = async (
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/prompts/
${
command
}
/update`
,
{
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/prompts/
command/
${
command
}
/update`
,
{
method
:
'
POST
'
,
headers
:
{
Accept
:
'
application/json
'
,
...
...
@@ -148,7 +148,7 @@ export const deletePromptByCommand = async (token: string, command: string) => {
command
=
command
.
charAt
(
0
)
===
'
/
'
?
command
.
slice
(
1
)
:
command
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/prompts/
${
command
}
/delete`
,
{
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/prompts/
command/
${
command
}
/delete`
,
{
method
:
'
DELETE
'
,
headers
:
{
Accept
:
'
application/json
'
,
...
...
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