Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/make selector sticky #84

Merged
merged 23 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f6d9a1c
feat: Make the space selector box stick to the top of the page.
osala-eng Aug 9, 2023
2a7d3f7
chore: Cleanup files.
osala-eng Aug 10, 2023
619ae81
chore: Add custom styling for personal ask.
osala-eng Aug 10, 2023
4057d6d
chore: Remove unused imports.
osala-eng Aug 10, 2023
e0bd220
Refactor: azureblob datasource (#79)
janaka Aug 10, 2023
6cf8d8e
chore: Add avatar to chat messages
osala-eng Aug 10, 2023
c4eafb4
chore: Added script to format avartars.
osala-eng Aug 11, 2023
b850565
feat: Make the space selector box stick to the top of the page.
osala-eng Aug 9, 2023
51293e2
chore: Remove unused imports.
osala-eng Aug 10, 2023
6afa2a9
Update user avatar settings.
osala-eng Aug 11, 2023
a0d7c04
chore: Attach event listeners to space selector.
osala-eng Aug 11, 2023
45b0992
chore: Cleanup imports.
osala-eng Aug 11, 2023
55a4e1c
chore: Update chat_ui script.
osala-eng Aug 12, 2023
934184e
feat: Make the space selector box stick to the top of the page.
osala-eng Aug 9, 2023
2c21968
chore: Cleanup files.
osala-eng Aug 12, 2023
67392ba
Merge branch 'main' into enhancement/make-selector-sticky
osala-eng Aug 12, 2023
f520bf0
chore: Use username as email for gravatar requests.
osala-eng Aug 16, 2023
a52f530
Merge branch 'main' into enhancement/make-selector-sticky
osala-eng Aug 16, 2023
1d1d8d9
chore: Use identicon as avatar default
osala-eng Aug 16, 2023
fa62517
chore: Set username in auth session state.
osala-eng Aug 16, 2023
10c6832
chore: Cleanup imports.
osala-eng Aug 16, 2023
2f4db5d
chore: Bump llama-index to 0.8.5.post2
osala-eng Aug 21, 2023
262a4c8
Update get username function
osala-eng Aug 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ packages = [
python = "^3.10"
streamlit = "^1.24.0"
st-pages = "^0.4.1"
llama-index = "0.7.4"
llama-index = "0.8.5.post2"
pypdf = "^3.9.0"
docx2txt = "^0.8"
argon2-cffi = "^21.3.0"
Expand Down
2 changes: 1 addition & 1 deletion source/docq/manage_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def authenticate(username: str, password: str) -> Tuple[int, str, bool]:
log.debug("User found: %s", selected)
(id_, saved_password, fullname, is_admin) = selected
try:
result = (id_, fullname, is_admin) if PH.verify(saved_password, password) else None
result = (id_, fullname, is_admin, username) if PH.verify(saved_password, password) else None
except VerificationError as e:
log.warning("Failing to authenticate user: %s for [%s]", username, e)
return None
Expand Down
1 change: 1 addition & 0 deletions web/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SessionKeyNameForAuth(Enum):
ID = "id"
NAME = "name"
ADMIN = "admin"
USERNAME = "username"


class SessionKeyNameForSettings(Enum):
Expand Down
13 changes: 13 additions & 0 deletions web/utils/handlers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Handlers for the web app."""

import asyncio
import hashlib
import logging as log
import math
from datetime import datetime
Expand Down Expand Up @@ -32,13 +33,15 @@
from .sessions import (
get_authenticated_user_id,
get_chat_session,
get_user_email,
osala-eng marked this conversation as resolved.
Show resolved Hide resolved
set_auth_session,
set_chat_session,
set_settings_session,
)


def handle_login(username: str, password: str) -> bool:
"""Handle login."""
result = manage_users.authenticate(username, password)
log.info("Login result: %s", result)
if result:
Expand All @@ -47,6 +50,7 @@ def handle_login(username: str, password: str) -> bool:
SessionKeyNameForAuth.ID.name: result[0],
SessionKeyNameForAuth.NAME.name: result[1],
SessionKeyNameForAuth.ADMIN.name: result[2],
SessionKeyNameForAuth.USERNAME.name: result[3],
}
)
set_settings_session(
Expand Down Expand Up @@ -363,3 +367,12 @@ def prepare_for_chat(feature: domain.FeatureKey) -> None:
feature.type_,
SessionKeyNameForChat.HISTORY,
)

def handle_get_gravatar_url() -> str:
"""Get Gravatar URL for the specified email."""
email = get_user_email()
if email is None:
email = "[email protected]"
size, default, rating = 200, "identicon", "g"
email_hash = hashlib.md5(email.lower().encode("utf-8")).hexdigest() # noqa: S324
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved Hide resolved
return f"https://www.gravatar.com/avatar/{email_hash}?s={size}&d={default}&r={rating}"
Loading
Loading