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
0c322063
Commit
0c322063
authored
Jan 26, 2024
by
Timothy J. Baek
Browse files
feat: use local profile image by default
parent
3ce8f3e8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
31 deletions
+72
-31
backend/apps/web/models/users.py
backend/apps/web/models/users.py
+1
-1
backend/apps/web/routers/utils.py
backend/apps/web/routers/utils.py
+8
-1
src/lib/apis/utils/index.ts
src/lib/apis/utils/index.ts
+23
-0
src/lib/components/chat/Settings/Account.svelte
src/lib/components/chat/Settings/Account.svelte
+40
-29
No files found.
backend/apps/web/models/users.py
View file @
0c322063
...
...
@@ -65,7 +65,7 @@ class UsersTable:
"name"
:
name
,
"email"
:
email
,
"role"
:
role
,
"profile_image_url"
:
get_gravatar_url
(
email
)
,
"profile_image_url"
:
"/user.png"
,
"timestamp"
:
int
(
time
.
time
()),
}
)
...
...
backend/apps/web/routers/utils.py
View file @
0c322063
...
...
@@ -9,7 +9,7 @@ import os
import
aiohttp
import
json
from
utils.misc
import
calculate_sha256
from
utils.misc
import
calculate_sha256
,
get_gravatar_url
from
config
import
OLLAMA_API_BASE_URL
,
DATA_DIR
,
UPLOAD_DIR
from
constants
import
ERROR_MESSAGES
...
...
@@ -165,3 +165,10 @@ def upload(file: UploadFile = File(...)):
yield
f
"data:
{
json
.
dumps
(
res
)
}
\n\n
"
return
StreamingResponse
(
file_process_stream
(),
media_type
=
"text/event-stream"
)
@
router
.
get
(
"/gravatar"
)
async
def
get_gravatar
(
email
:
str
,
):
return
get_gravatar_url
(
email
)
src/lib/apis/utils/index.ts
0 → 100644
View file @
0c322063
import
{
WEBUI_API_BASE_URL
}
from
'
$lib/constants
'
;
export
const
getGravatarUrl
=
async
(
email
:
string
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/utils/gravatar?email=
${
email
}
`
,
{
method
:
'
GET
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
})
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
error
=
err
;
return
null
;
});
return
res
;
};
src/lib/components/chat/Settings/Account.svelte
View file @
0c322063
...
...
@@ -6,6 +6,7 @@
import { updateUserProfile } from '$lib/apis/auths';
import UpdatePassword from './Account/UpdatePassword.svelte';
import { getGravatarUrl } from '$lib/apis/utils';
export let saveHandler: Function;
...
...
@@ -98,6 +99,7 @@
<div class=" mb-2.5 font-medium">Profile</div>
<div class="flex space-x-5">
<div class="flex flex-col">
<div class="self-center">
<button
class="relative rounded-full dark:bg-gray-700"
...
...
@@ -130,6 +132,15 @@
</div>
</button>
</div>
<button
class=" text-xs text-gray-600"
on:click={async () => {
const url = await getGravatarUrl($user.email);
profileImageUrl = url;
}}>Use Gravatar</button
>
</div>
<div class="flex-1">
<div class="flex flex-col w-full">
...
...
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