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
2f23325c
Unverified
Commit
2f23325c
authored
Mar 31, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Mar 31, 2024
Browse files
Merge branch 'dev' into fix/data-dir-handling
parents
cef67642
587a8c59
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1566 additions
and
1542 deletions
+1566
-1542
.github/workflows/format-backend.yaml
.github/workflows/format-backend.yaml
+21
-11
.github/workflows/format-build-frontend.yaml
.github/workflows/format-build-frontend.yaml
+27
-16
backend/apps/images/main.py
backend/apps/images/main.py
+3
-3
backend/apps/images/utils/comfyui.py
backend/apps/images/utils/comfyui.py
+13
-7
backend/apps/ollama/main.py
backend/apps/ollama/main.py
+2
-2
backend/apps/rag/main.py
backend/apps/rag/main.py
+3
-3
backend/config.py
backend/config.py
+2
-0
backend/data/config.json
backend/data/config.json
+23
-35
backend/utils/webhook.py
backend/utils/webhook.py
+9
-2
package-lock.json
package-lock.json
+2
-2
package.json
package.json
+1
-2
src/lib/i18n/locales/ca-ES/translation.json
src/lib/i18n/locales/ca-ES/translation.json
+1
-1
src/lib/i18n/locales/it-IT/translation.json
src/lib/i18n/locales/it-IT/translation.json
+363
-363
src/lib/i18n/locales/ja-JP/translation.json
src/lib/i18n/locales/ja-JP/translation.json
+363
-363
src/lib/i18n/locales/languages.json
src/lib/i18n/locales/languages.json
+1
-1
src/lib/i18n/locales/pt-PT/translation.json
src/lib/i18n/locales/pt-PT/translation.json
+363
-363
src/lib/i18n/locales/ru-RU/translation.json
src/lib/i18n/locales/ru-RU/translation.json
+1
-1
src/lib/i18n/locales/vi-VN/translation.json
src/lib/i18n/locales/vi-VN/translation.json
+362
-362
src/tailwind.css
src/tailwind.css
+5
-4
static/manifest.json
static/manifest.json
+1
-1
No files found.
.github/workflows/format-backend.yaml
View file @
2f23325c
name
:
Python CI
name
:
Python CI
on
:
on
:
push
:
push
:
branches
:
[
'
main'
]
branches
:
-
main
-
dev
pull_request
:
pull_request
:
branches
:
-
main
-
dev
jobs
:
jobs
:
build
:
build
:
name
:
'
Format
Backend'
name
:
'
Format
Backend'
env
:
PUBLIC_API_BASE_URL
:
'
'
runs-on
:
ubuntu-latest
runs-on
:
ubuntu-latest
strategy
:
strategy
:
matrix
:
matrix
:
node
-version
:
python
-version
:
[
3.11
]
-
latest
steps
:
steps
:
-
uses
:
actions/checkout@v4
-
uses
:
actions/checkout@v4
-
name
:
Use Python
uses
:
actions/setup-python@v4
-
name
:
Set up Python
-
name
:
Use Bun
uses
:
actions/setup-python@v2
uses
:
oven-sh/setup-bun@v1
with
:
python-version
:
${{ matrix.python-version }}
-
name
:
Install dependencies
-
name
:
Install dependencies
run
:
|
run
:
|
python -m pip install --upgrade pip
python -m pip install --upgrade pip
pip install yapf
pip install black
-
name
:
Format backend
-
name
:
Format backend
run
:
bun run format:backend
run
:
black . --exclude "/venv/"
-
name
:
Check for changes after format
-
name
:
Check for changes after format
run
:
git diff --exit-code
run
:
git diff --exit-code
.github/workflows/format-build-frontend.yaml
View file @
2f23325c
name
:
Bun CI
name
:
Frontend Build
on
:
on
:
push
:
push
:
branches
:
[
'
main'
]
branches
:
-
main
-
dev
pull_request
:
pull_request
:
branches
:
-
main
-
dev
jobs
:
jobs
:
build
:
build
:
name
:
'
Format
&
Build
Frontend'
name
:
'
Format
&
Build
Frontend'
env
:
PUBLIC_API_BASE_URL
:
'
'
runs-on
:
ubuntu-latest
runs-on
:
ubuntu-latest
steps
:
steps
:
-
uses
:
actions/checkout@v4
-
name
:
Checkout Repository
-
name
:
Use Bun
uses
:
actions/checkout@v4
uses
:
oven-sh/setup-bun@v1
-
run
:
bun --version
-
name
:
Setup Node.js
-
name
:
Install frontend dependencies
uses
:
actions/setup-node@v3
run
:
bun install
with
:
-
name
:
Format frontend
node-version
:
'
20'
# Or specify any other version you want to use
run
:
bun run format
-
name
:
Check for changes after format
-
name
:
Install Dependencies
run
:
npm install
-
name
:
Format Frontend
run
:
npm run format
-
name
:
Check for Changes After Format
run
:
git diff --exit-code
run
:
git diff --exit-code
-
name
:
Build frontend
if
:
always()
-
name
:
Build Frontend
run
:
bun
run build
run
:
npm
run build
backend/apps/images/main.py
View file @
2f23325c
...
@@ -325,7 +325,7 @@ def save_url_image(url):
...
@@ -325,7 +325,7 @@ def save_url_image(url):
return
image_id
return
image_id
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"Error saving image:
{
e
}
"
)
log
.
exception
(
f
"Error saving image:
{
e
}
"
)
return
None
return
None
...
@@ -397,7 +397,7 @@ def generate_image(
...
@@ -397,7 +397,7 @@ def generate_image(
user
.
id
,
user
.
id
,
app
.
state
.
COMFYUI_BASE_URL
,
app
.
state
.
COMFYUI_BASE_URL
,
)
)
print
(
res
)
log
.
debug
(
f
"res:
{
res
}
"
)
images
=
[]
images
=
[]
...
@@ -409,7 +409,7 @@ def generate_image(
...
@@ -409,7 +409,7 @@ def generate_image(
with
open
(
file_body_path
,
"w"
)
as
f
:
with
open
(
file_body_path
,
"w"
)
as
f
:
json
.
dump
(
data
.
model_dump
(
exclude_none
=
True
),
f
)
json
.
dump
(
data
.
model_dump
(
exclude_none
=
True
),
f
)
print
(
images
)
log
.
debug
(
f
"images:
{
images
}
"
)
return
images
return
images
else
:
else
:
if
form_data
.
model
:
if
form_data
.
model
:
...
...
backend/apps/images/utils/comfyui.py
View file @
2f23325c
...
@@ -4,6 +4,12 @@ import json
...
@@ -4,6 +4,12 @@ import json
import
urllib.request
import
urllib.request
import
urllib.parse
import
urllib.parse
import
random
import
random
import
logging
from
config
import
SRC_LOG_LEVELS
log
=
logging
.
getLogger
(
__name__
)
log
.
setLevel
(
SRC_LOG_LEVELS
[
"COMFYUI"
])
from
pydantic
import
BaseModel
from
pydantic
import
BaseModel
...
@@ -121,7 +127,7 @@ COMFYUI_DEFAULT_PROMPT = """
...
@@ -121,7 +127,7 @@ COMFYUI_DEFAULT_PROMPT = """
def
queue_prompt
(
prompt
,
client_id
,
base_url
):
def
queue_prompt
(
prompt
,
client_id
,
base_url
):
print
(
"queue_prompt"
)
log
.
info
(
"queue_prompt"
)
p
=
{
"prompt"
:
prompt
,
"client_id"
:
client_id
}
p
=
{
"prompt"
:
prompt
,
"client_id"
:
client_id
}
data
=
json
.
dumps
(
p
).
encode
(
"utf-8"
)
data
=
json
.
dumps
(
p
).
encode
(
"utf-8"
)
req
=
urllib
.
request
.
Request
(
f
"
{
base_url
}
/prompt"
,
data
=
data
)
req
=
urllib
.
request
.
Request
(
f
"
{
base_url
}
/prompt"
,
data
=
data
)
...
@@ -129,7 +135,7 @@ def queue_prompt(prompt, client_id, base_url):
...
@@ -129,7 +135,7 @@ def queue_prompt(prompt, client_id, base_url):
def
get_image
(
filename
,
subfolder
,
folder_type
,
base_url
):
def
get_image
(
filename
,
subfolder
,
folder_type
,
base_url
):
print
(
"get_image"
)
log
.
info
(
"get_image"
)
data
=
{
"filename"
:
filename
,
"subfolder"
:
subfolder
,
"type"
:
folder_type
}
data
=
{
"filename"
:
filename
,
"subfolder"
:
subfolder
,
"type"
:
folder_type
}
url_values
=
urllib
.
parse
.
urlencode
(
data
)
url_values
=
urllib
.
parse
.
urlencode
(
data
)
with
urllib
.
request
.
urlopen
(
f
"
{
base_url
}
/view?
{
url_values
}
"
)
as
response
:
with
urllib
.
request
.
urlopen
(
f
"
{
base_url
}
/view?
{
url_values
}
"
)
as
response
:
...
@@ -137,14 +143,14 @@ def get_image(filename, subfolder, folder_type, base_url):
...
@@ -137,14 +143,14 @@ def get_image(filename, subfolder, folder_type, base_url):
def
get_image_url
(
filename
,
subfolder
,
folder_type
,
base_url
):
def
get_image_url
(
filename
,
subfolder
,
folder_type
,
base_url
):
print
(
"get_image"
)
log
.
info
(
"get_image"
)
data
=
{
"filename"
:
filename
,
"subfolder"
:
subfolder
,
"type"
:
folder_type
}
data
=
{
"filename"
:
filename
,
"subfolder"
:
subfolder
,
"type"
:
folder_type
}
url_values
=
urllib
.
parse
.
urlencode
(
data
)
url_values
=
urllib
.
parse
.
urlencode
(
data
)
return
f
"
{
base_url
}
/view?
{
url_values
}
"
return
f
"
{
base_url
}
/view?
{
url_values
}
"
def
get_history
(
prompt_id
,
base_url
):
def
get_history
(
prompt_id
,
base_url
):
print
(
"get_history"
)
log
.
info
(
"get_history"
)
with
urllib
.
request
.
urlopen
(
f
"
{
base_url
}
/history/
{
prompt_id
}
"
)
as
response
:
with
urllib
.
request
.
urlopen
(
f
"
{
base_url
}
/history/
{
prompt_id
}
"
)
as
response
:
return
json
.
loads
(
response
.
read
())
return
json
.
loads
(
response
.
read
())
...
@@ -212,15 +218,15 @@ def comfyui_generate_image(
...
@@ -212,15 +218,15 @@ def comfyui_generate_image(
try
:
try
:
ws
=
websocket
.
WebSocket
()
ws
=
websocket
.
WebSocket
()
ws
.
connect
(
f
"ws://
{
host
}
/ws?clientId=
{
client_id
}
"
)
ws
.
connect
(
f
"ws://
{
host
}
/ws?clientId=
{
client_id
}
"
)
print
(
"WebSocket connection established."
)
log
.
info
(
"WebSocket connection established."
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"Failed to connect to WebSocket server:
{
e
}
"
)
log
.
exception
(
f
"Failed to connect to WebSocket server:
{
e
}
"
)
return
None
return
None
try
:
try
:
images
=
get_images
(
ws
,
comfyui_prompt
,
client_id
,
base_url
)
images
=
get_images
(
ws
,
comfyui_prompt
,
client_id
,
base_url
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"Error while receiving images:
{
e
}
"
)
log
.
exception
(
f
"Error while receiving images:
{
e
}
"
)
images
=
None
images
=
None
ws
.
close
()
ws
.
close
()
...
...
backend/apps/ollama/main.py
View file @
2f23325c
...
@@ -272,7 +272,7 @@ async def pull_model(
...
@@ -272,7 +272,7 @@ async def pull_model(
if
request_id
in
REQUEST_POOL
:
if
request_id
in
REQUEST_POOL
:
yield
chunk
yield
chunk
else
:
else
:
pr
in
t
(
"User: canceled request"
)
log
.
warn
in
g
(
"User: canceled request"
)
break
break
finally
:
finally
:
if
hasattr
(
r
,
"close"
):
if
hasattr
(
r
,
"close"
):
...
@@ -670,7 +670,7 @@ async def generate_completion(
...
@@ -670,7 +670,7 @@ async def generate_completion(
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
400
,
status_code
=
400
,
detail
=
"err
or_d
e
ta
il"
,
detail
=
ERROR_MESSAGES
.
MODEL_NOT_FOUND
(
f
or
m
_d
a
ta
.
model
)
,
)
)
url
=
app
.
state
.
OLLAMA_BASE_URLS
[
url_idx
]
url
=
app
.
state
.
OLLAMA_BASE_URLS
[
url_idx
]
...
...
backend/apps/rag/main.py
View file @
2f23325c
...
@@ -333,7 +333,7 @@ def store_docs_in_vector_db(docs, collection_name, overwrite: bool = False) -> b
...
@@ -333,7 +333,7 @@ def store_docs_in_vector_db(docs, collection_name, overwrite: bool = False) -> b
if
overwrite
:
if
overwrite
:
for
collection
in
CHROMA_CLIENT
.
list_collections
():
for
collection
in
CHROMA_CLIENT
.
list_collections
():
if
collection_name
==
collection
.
name
:
if
collection_name
==
collection
.
name
:
print
(
f
"deleting existing collection
{
collection_name
}
"
)
log
.
info
(
f
"deleting existing collection
{
collection_name
}
"
)
CHROMA_CLIENT
.
delete_collection
(
name
=
collection_name
)
CHROMA_CLIENT
.
delete_collection
(
name
=
collection_name
)
collection
=
CHROMA_CLIENT
.
create_collection
(
collection
=
CHROMA_CLIENT
.
create_collection
(
...
@@ -346,7 +346,7 @@ def store_docs_in_vector_db(docs, collection_name, overwrite: bool = False) -> b
...
@@ -346,7 +346,7 @@ def store_docs_in_vector_db(docs, collection_name, overwrite: bool = False) -> b
)
)
return
True
return
True
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
log
.
exception
(
e
)
if
e
.
__class__
.
__name__
==
"UniqueConstraintError"
:
if
e
.
__class__
.
__name__
==
"UniqueConstraintError"
:
return
True
return
True
...
@@ -575,7 +575,7 @@ def scan_docs_dir(user=Depends(get_admin_user)):
...
@@ -575,7 +575,7 @@ def scan_docs_dir(user=Depends(get_admin_user)):
),
),
)
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
log
.
exception
(
e
)
pass
pass
except
Exception
as
e
:
except
Exception
as
e
:
...
...
backend/config.py
View file @
2f23325c
...
@@ -119,6 +119,7 @@ log.info(f"GLOBAL_LOG_LEVEL: {GLOBAL_LOG_LEVEL}")
...
@@ -119,6 +119,7 @@ log.info(f"GLOBAL_LOG_LEVEL: {GLOBAL_LOG_LEVEL}")
log_sources
=
[
log_sources
=
[
"AUDIO"
,
"AUDIO"
,
"COMFYUI"
,
"CONFIG"
,
"CONFIG"
,
"DB"
,
"DB"
,
"IMAGES"
,
"IMAGES"
,
...
@@ -128,6 +129,7 @@ log_sources = [
...
@@ -128,6 +129,7 @@ log_sources = [
"OLLAMA"
,
"OLLAMA"
,
"OPENAI"
,
"OPENAI"
,
"RAG"
,
"RAG"
,
"WEBHOOK"
,
]
]
SRC_LOG_LEVELS
=
{}
SRC_LOG_LEVELS
=
{}
...
...
backend/data/config.json
View file @
2f23325c
...
@@ -4,31 +4,19 @@
...
@@ -4,31 +4,19 @@
"default_locale"
:
"en-US"
,
"default_locale"
:
"en-US"
,
"prompt_suggestions"
:
[
"prompt_suggestions"
:
[
{
{
"title"
:
[
"title"
:
[
"Help me study"
,
"vocabulary for a college entrance exam"
],
"Help me study"
,
"vocabulary for a college entrance exam"
],
"content"
:
"Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option."
"content"
:
"Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option."
},
},
{
{
"title"
:
[
"title"
:
[
"Give me ideas"
,
"for what to do with my kids' art"
],
"Give me ideas"
,
"for what to do with my kids' art"
],
"content"
:
"What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter."
"content"
:
"What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter."
},
},
{
{
"title"
:
[
"title"
:
[
"Tell me a fun fact"
,
"about the Roman Empire"
],
"Tell me a fun fact"
,
"about the Roman Empire"
],
"content"
:
"Tell me a random fun fact about the Roman Empire"
"content"
:
"Tell me a random fun fact about the Roman Empire"
},
},
{
{
"title"
:
[
"title"
:
[
"Show me a code snippet"
,
"of a website's sticky header"
],
"Show me a code snippet"
,
"of a website's sticky header"
],
"content"
:
"Show me a code snippet of a website's sticky header in CSS and JavaScript."
"content"
:
"Show me a code snippet of a website's sticky header in CSS and JavaScript."
}
}
]
]
...
...
backend/utils/webhook.py
View file @
2f23325c
import
json
import
json
import
requests
import
requests
from
config
import
VERSION
,
WEBUI_FAVICON_URL
,
WEBUI_NAME
import
logging
from
config
import
SRC_LOG_LEVELS
,
VERSION
,
WEBUI_FAVICON_URL
,
WEBUI_NAME
log
=
logging
.
getLogger
(
__name__
)
log
.
setLevel
(
SRC_LOG_LEVELS
[
"WEBHOOK"
])
def
post_webhook
(
url
:
str
,
message
:
str
,
event_data
:
dict
)
->
bool
:
def
post_webhook
(
url
:
str
,
message
:
str
,
event_data
:
dict
)
->
bool
:
...
@@ -39,9 +44,11 @@ def post_webhook(url: str, message: str, event_data: dict) -> bool:
...
@@ -39,9 +44,11 @@ def post_webhook(url: str, message: str, event_data: dict) -> bool:
else
:
else
:
payload
=
{
**
event_data
}
payload
=
{
**
event_data
}
log
.
debug
(
f
"payload:
{
payload
}
"
)
r
=
requests
.
post
(
url
,
json
=
payload
)
r
=
requests
.
post
(
url
,
json
=
payload
)
r
.
raise_for_status
()
r
.
raise_for_status
()
log
.
debug
(
f
"r.text:
{
r
.
text
}
"
)
return
True
return
True
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
log
.
exception
(
e
)
return
False
return
False
package-lock.json
View file @
2f23325c
{
{
"name"
:
"open-webui"
,
"name"
:
"open-webui"
,
"version"
:
"0.1.11
4
"
,
"version"
:
"0.1.11
6
"
,
"lockfileVersion"
:
3
,
"lockfileVersion"
:
3
,
"requires"
:
true
,
"requires"
:
true
,
"packages"
:
{
"packages"
:
{
""
:
{
""
:
{
"name"
:
"open-webui"
,
"name"
:
"open-webui"
,
"version"
:
"0.1.11
4
"
,
"version"
:
"0.1.11
6
"
,
"dependencies"
:
{
"dependencies"
:
{
"@sveltejs/adapter-node"
:
"^1.3.1"
,
"@sveltejs/adapter-node"
:
"^1.3.1"
,
"async"
:
"^3.2.5"
,
"async"
:
"^3.2.5"
,
...
...
package.json
View file @
2f23325c
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
"lint:types"
:
"npm run check"
,
"lint:types"
:
"npm run check"
,
"lint:backend"
:
"pylint backend/"
,
"lint:backend"
:
"pylint backend/"
,
"format"
:
"prettier --plugin-search-dir --write '**/*.{js,ts,svelte,css,md,html,json}'"
,
"format"
:
"prettier --plugin-search-dir --write '**/*.{js,ts,svelte,css,md,html,json}'"
,
"format:backend"
:
"yapf --recursive backend -p -i"
,
"i18n:parse"
:
"i18next --config i18next-parser.config.ts && prettier --write 'src/lib/i18n/**/*.{js,json}'"
"i18n:parse"
:
"i18next --config i18next-parser.config.ts && prettier --write 'src/lib/i18n/**/*.{js,json}'"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
...
...
src/lib/i18n/locales/ca-ES/translation.json
View file @
2f23325c
src/lib/i18n/locales/it-IT/translation.json
View file @
2f23325c
...
@@ -360,4 +360,4 @@
...
@@ -360,4 +360,4 @@
"You"
:
"Tu"
,
"You"
:
"Tu"
,
"You're a helpful assistant."
:
"Sei un assistente utile."
,
"You're a helpful assistant."
:
"Sei un assistente utile."
,
"You're now logged in."
:
"Ora hai effettuato l'accesso."
"You're now logged in."
:
"Ora hai effettuato l'accesso."
}
}
\ No newline at end of file
src/lib/i18n/locales/ja-JP/translation.json
View file @
2f23325c
...
@@ -360,4 +360,4 @@
...
@@ -360,4 +360,4 @@
"You"
:
"あなた"
,
"You"
:
"あなた"
,
"You're a helpful assistant."
:
"あなたは役に立つアシスタントです。"
,
"You're a helpful assistant."
:
"あなたは役に立つアシスタントです。"
,
"You're now logged in."
:
"ログインしました。"
"You're now logged in."
:
"ログインしました。"
}
}
\ No newline at end of file
src/lib/i18n/locales/languages.json
View file @
2f23325c
src/lib/i18n/locales/pt-PT/translation.json
View file @
2f23325c
src/lib/i18n/locales/ru-RU/translation.json
View file @
2f23325c
src/lib/i18n/locales/vi-VN/translation.json
View file @
2f23325c
src/tailwind.css
View file @
2f23325c
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
@tailwind
utilities
;
@tailwind
utilities
;
@layer
base
{
@layer
base
{
html
,
pre
{
html
,
pre
{
font-family
:
-apple-system
,
'Arimo'
,
ui-sans-serif
,
system-ui
,
'Segoe UI'
,
Roboto
,
Ubuntu
,
font-family
:
-apple-system
,
'Arimo'
,
ui-sans-serif
,
system-ui
,
'Segoe UI'
,
Roboto
,
Ubuntu
,
Cantarell
,
'Noto Sans'
,
sans-serif
,
'Helvetica Neue'
,
Arial
,
'Apple Color Emoji'
,
Cantarell
,
'Noto Sans'
,
sans-serif
,
'Helvetica Neue'
,
Arial
,
'Apple Color Emoji'
,
'Segoe UI Emoji'
,
'Segoe UI Symbol'
,
'Noto Color Emoji'
;
'Segoe UI Emoji'
,
'Segoe UI Symbol'
,
'Noto Color Emoji'
;
...
...
static/manifest.json
View file @
2f23325c
Prev
1
2
Next
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