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
427ca4e3
Unverified
Commit
427ca4e3
authored
Mar 26, 2024
by
changchiyou
Browse files
refactor: dynamically swap `activitySubtitle` and `activityImage` if `CUSTOM_NAME` has been set
parent
5eac5c54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
backend/config.py
backend/config.py
+10
-12
backend/utils/webhook.py
backend/utils/webhook.py
+3
-3
No files found.
backend/config.py
View file @
427ca4e3
import
json
import
os
import
os
import
chromadb
import
shutil
from
chromadb
import
Settings
from
base64
import
b64encode
from
base64
import
b64encode
from
bs4
import
BeautifulSoup
from
pathlib
import
Path
from
pathlib
import
Path
import
json
from
secrets
import
token_bytes
import
yaml
import
chromadb
import
markdown
import
markdown
import
requests
import
requests
import
shuti
l
import
yam
l
from
bs4
import
BeautifulSoup
from
secrets
import
token_byte
s
from
chromadb
import
Setting
s
from
constants
import
ERROR_MESSAGES
from
constants
import
ERROR_MESSAGES
try
:
try
:
from
dotenv
import
loa
d_dotenv
,
fin
d_dotenv
from
dotenv
import
fin
d_dotenv
,
loa
d_dotenv
load_dotenv
(
find_dotenv
(
"../.env"
))
load_dotenv
(
find_dotenv
(
"../.env"
))
except
ImportError
:
except
ImportError
:
print
(
"dotenv not installed, skipping..."
)
print
(
"dotenv not installed, skipping..."
)
WEBUI_NAME
=
"Open WebUI"
WEBUI_NAME
=
"Open WebUI"
WEBUI_FAVICON_URL
=
"https://openwebui.com/favicon.png"
shutil
.
copyfile
(
"../build/favicon.png"
,
"./static/favicon.png"
)
shutil
.
copyfile
(
"../build/favicon.png"
,
"./static/favicon.png"
)
####################################
####################################
...
@@ -111,7 +109,7 @@ if CUSTOM_NAME:
...
@@ -111,7 +109,7 @@ if CUSTOM_NAME:
data
=
r
.
json
()
data
=
r
.
json
()
if
r
.
ok
:
if
r
.
ok
:
if
"logo"
in
data
:
if
"logo"
in
data
:
url
=
(
WEBUI_FAVICON_URL
=
url
=
(
f
"https://api.openwebui.com
{
data
[
'logo'
]
}
"
f
"https://api.openwebui.com
{
data
[
'logo'
]
}
"
if
data
[
"logo"
][
0
]
==
"/"
if
data
[
"logo"
][
0
]
==
"/"
else
data
[
"logo"
]
else
data
[
"logo"
]
...
...
backend/utils/webhook.py
View file @
427ca4e3
import
json
import
json
import
requests
import
requests
from
config
import
VERSION
from
config
import
VERSION
,
WEBUI_FAVICON_URL
,
WEBUI_NAME
def
post_webhook
(
url
:
str
,
message
:
str
,
event_data
:
dict
)
->
bool
:
def
post_webhook
(
url
:
str
,
message
:
str
,
event_data
:
dict
)
->
bool
:
...
@@ -26,8 +26,8 @@ def post_webhook(url: str, message: str, event_data: dict) -> bool:
...
@@ -26,8 +26,8 @@ def post_webhook(url: str, message: str, event_data: dict) -> bool:
"sections"
:
[
"sections"
:
[
{
{
"activityTitle"
:
message
,
"activityTitle"
:
message
,
"activitySubtitle"
:
f
"
Open WebUI
(
{
VERSION
}
) -
{
action
}
"
,
"activitySubtitle"
:
f
"
{
WEBUI_NAME
}
(
{
VERSION
}
) -
{
action
}
"
,
"activityImage"
:
"https://openwebui.com/favicon.png"
,
"activityImage"
:
WEBUI_FAVICON_URL
,
"facts"
:
facts
,
"facts"
:
facts
,
"markdown"
:
True
,
"markdown"
:
True
,
}
}
...
...
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