Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions bin/chat-chainlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,25 @@ def get_data_layer() -> BaseDataLayer:
providers.append(ORCIDOAuthProvider())

if os.getenv("CHAINLIT_AUTH_SECRET"):

# chainlit 2.1 made this async and added the OIDC id_token as a fifth
# argument. Neither is optional: chainlit awaits the result and calls it with
# five arguments, so the old sync four-argument version would have failed at
# login rather than at import.
@cl.oauth_callback
def oauth_callback(
async def oauth_callback(
provider_id: str,
token: str,
raw_user_data: dict[str, str],
default_user: cl.User,
id_token: str | None = None,
) -> cl.User | None:
return default_user


# chainlit 2.1 passes the current user, so a deployment can vary the profile
# list per user. This one does not, but the parameter is required.
@cl.set_chat_profiles
async def chat_profiles() -> list[cl.ChatProfile]:
async def chat_profiles(user: cl.User | None = None) -> list[cl.ChatProfile]:
return [
cl.ChatProfile(
name=profile.name,
Expand Down
Loading
Loading