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
038fc48a
Commit
038fc48a
authored
Aug 14, 2024
by
Michael Poluektov
Browse files
replace == None with is None
parent
6f72def1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
backend/apps/images/main.py
backend/apps/images/main.py
+4
-4
backend/apps/rag/main.py
backend/apps/rag/main.py
+4
-4
backend/apps/webui/models/tags.py
backend/apps/webui/models/tags.py
+1
-1
backend/apps/webui/routers/documents.py
backend/apps/webui/routers/documents.py
+1
-1
backend/apps/webui/routers/functions.py
backend/apps/webui/routers/functions.py
+1
-1
backend/apps/webui/routers/prompts.py
backend/apps/webui/routers/prompts.py
+1
-1
No files found.
backend/apps/images/main.py
View file @
038fc48a
...
...
@@ -94,7 +94,7 @@ app.state.config.COMFYUI_FLUX_FP8_CLIP = COMFYUI_FLUX_FP8_CLIP
def
get_automatic1111_api_auth
():
if
app
.
state
.
config
.
AUTOMATIC1111_API_AUTH
==
None
:
if
app
.
state
.
config
.
AUTOMATIC1111_API_AUTH
is
None
:
return
""
else
:
auth1111_byte_string
=
app
.
state
.
config
.
AUTOMATIC1111_API_AUTH
.
encode
(
"utf-8"
)
...
...
@@ -145,7 +145,7 @@ async def get_engine_url(user=Depends(get_admin_user)):
async
def
update_engine_url
(
form_data
:
EngineUrlUpdateForm
,
user
=
Depends
(
get_admin_user
)
):
if
form_data
.
AUTOMATIC1111_BASE_URL
==
None
:
if
form_data
.
AUTOMATIC1111_BASE_URL
is
None
:
app
.
state
.
config
.
AUTOMATIC1111_BASE_URL
=
AUTOMATIC1111_BASE_URL
else
:
url
=
form_data
.
AUTOMATIC1111_BASE_URL
.
strip
(
"/"
)
...
...
@@ -156,7 +156,7 @@ async def update_engine_url(
except
Exception
as
e
:
raise
HTTPException
(
status_code
=
400
,
detail
=
ERROR_MESSAGES
.
INVALID_URL
)
if
form_data
.
COMFYUI_BASE_URL
==
None
:
if
form_data
.
COMFYUI_BASE_URL
is
None
:
app
.
state
.
config
.
COMFYUI_BASE_URL
=
COMFYUI_BASE_URL
else
:
url
=
form_data
.
COMFYUI_BASE_URL
.
strip
(
"/"
)
...
...
@@ -168,7 +168,7 @@ async def update_engine_url(
except
Exception
as
e
:
raise
HTTPException
(
status_code
=
400
,
detail
=
ERROR_MESSAGES
.
INVALID_URL
)
if
form_data
.
AUTOMATIC1111_API_AUTH
==
None
:
if
form_data
.
AUTOMATIC1111_API_AUTH
is
None
:
app
.
state
.
config
.
AUTOMATIC1111_API_AUTH
=
AUTOMATIC1111_API_AUTH
else
:
app
.
state
.
config
.
AUTOMATIC1111_API_AUTH
=
form_data
.
AUTOMATIC1111_API_AUTH
...
...
backend/apps/rag/main.py
View file @
038fc48a
...
...
@@ -1185,7 +1185,7 @@ def store_doc(
f
.
close
()
f
=
open
(
file_path
,
"rb"
)
if
collection_name
==
None
:
if
collection_name
is
None
:
collection_name
=
calculate_sha256
(
f
)[:
63
]
f
.
close
()
...
...
@@ -1238,7 +1238,7 @@ def process_doc(
f
=
open
(
file_path
,
"rb"
)
collection_name
=
form_data
.
collection_name
if
collection_name
==
None
:
if
collection_name
is
None
:
collection_name
=
calculate_sha256
(
f
)[:
63
]
f
.
close
()
...
...
@@ -1296,7 +1296,7 @@ def store_text(
):
collection_name
=
form_data
.
collection_name
if
collection_name
==
None
:
if
collection_name
is
None
:
collection_name
=
calculate_sha256_string
(
form_data
.
content
)
result
=
store_text_in_vector_db
(
...
...
@@ -1339,7 +1339,7 @@ def scan_docs_dir(user=Depends(get_admin_user)):
sanitized_filename
=
sanitize_filename
(
filename
)
doc
=
Documents
.
get_doc_by_name
(
sanitized_filename
)
if
doc
==
None
:
if
doc
is
None
:
doc
=
Documents
.
insert_new_doc
(
user
.
id
,
DocumentForm
(
...
...
backend/apps/webui/models/tags.py
View file @
038fc48a
...
...
@@ -109,7 +109,7 @@ class TagTable:
self
,
user_id
:
str
,
form_data
:
ChatIdTagForm
)
->
Optional
[
ChatIdTagModel
]:
tag
=
self
.
get_tag_by_name_and_user_id
(
form_data
.
tag_name
,
user_id
)
if
tag
==
None
:
if
tag
is
None
:
tag
=
self
.
insert_new_tag
(
form_data
.
tag_name
,
user_id
)
id
=
str
(
uuid
.
uuid4
())
...
...
backend/apps/webui/routers/documents.py
View file @
038fc48a
...
...
@@ -46,7 +46,7 @@ async def get_documents(user=Depends(get_verified_user)):
@
router
.
post
(
"/create"
,
response_model
=
Optional
[
DocumentResponse
])
async
def
create_new_doc
(
form_data
:
DocumentForm
,
user
=
Depends
(
get_admin_user
)):
doc
=
Documents
.
get_doc_by_name
(
form_data
.
name
)
if
doc
==
None
:
if
doc
is
None
:
doc
=
Documents
.
insert_new_doc
(
user
.
id
,
form_data
)
if
doc
:
...
...
backend/apps/webui/routers/functions.py
View file @
038fc48a
...
...
@@ -63,7 +63,7 @@ async def create_new_function(
form_data
.
id
=
form_data
.
id
.
lower
()
function
=
Functions
.
get_function_by_id
(
form_data
.
id
)
if
function
==
None
:
if
function
is
None
:
function_path
=
os
.
path
.
join
(
FUNCTIONS_DIR
,
f
"
{
form_data
.
id
}
.py"
)
try
:
with
open
(
function_path
,
"w"
)
as
function_file
:
...
...
backend/apps/webui/routers/prompts.py
View file @
038fc48a
...
...
@@ -31,7 +31,7 @@ async def get_prompts(user=Depends(get_verified_user)):
@
router
.
post
(
"/create"
,
response_model
=
Optional
[
PromptModel
])
async
def
create_new_prompt
(
form_data
:
PromptForm
,
user
=
Depends
(
get_admin_user
)):
prompt
=
Prompts
.
get_prompt_by_command
(
form_data
.
command
)
if
prompt
==
None
:
if
prompt
is
None
:
prompt
=
Prompts
.
insert_new_prompt
(
user
.
id
,
form_data
)
if
prompt
:
...
...
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