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

Auth + async answer + loading indicator in placeholder #135

Merged
merged 20 commits into from
Nov 1, 2023

Conversation

pierrotsmnrd
Copy link
Contributor

@pierrotsmnrd pierrotsmnrd commented Oct 30, 2023

Async answer for a better, non-blocking UX when asking a question.

Making it async revealed the default loading indicator of Panel's chat message, so I replaced it with one with Ragna's colors.

UPDATE : also contains Auth after a rebase, see PR #137

@pierrotsmnrd pierrotsmnrd requested a review from pmeier October 30, 2023 16:49
ragna/_ui/api_wrapper.py Outdated Show resolved Hide resolved
ragna/_ui/central_view.py Outdated Show resolved Hide resolved
@pmeier
Copy link
Member

pmeier commented Oct 31, 2023

@pierrotsmnrd I've pushed 094105c to get rid of all the sync API calls. Unfortunately, this PR seems to be mixed with #137 and I'm facing issues there. Meaning, I can't properly review this one.

@pierrotsmnrd
Copy link
Contributor Author

pierrotsmnrd commented Nov 1, 2023

Thanks for that, that's the piece I have been looking for. I wish asyncio's docs were clearer.

One issue though : Now the RagnaAuthTokenExpiredException is not caught anymore using asyncio.ensure_future.
This prevents the broken UI you had described in PR137 after restarting the API (the reason is an invalid token).

The two PRs are not "mixed", the branch async_api_wrapper has been rebased on auth to reduce the conflicts on api_wrapper. I'm going to close PR #135 as this use supersedes it.

@pierrotsmnrd pierrotsmnrd mentioned this pull request Nov 1, 2023
@pierrotsmnrd pierrotsmnrd changed the title async answer + loading indicator in placeholder Auth + async answer + loading indicator in placeholder Nov 1, 2023
pierrotsmnrd and others added 3 commits November 1, 2023 06:18
commit 9b721fd
Author: Philip Meier <github.pmeier@posteo.de>
Date:   Wed Nov 1 14:08:20 2023 +0100

    allow API token secret to be set through env var (#141)

commit 17c227e
Author: Philip Meier <github.pmeier@posteo.de>
Date:   Wed Nov 1 10:13:08 2023 +0100

    dont create DB session as dependency (#138)
ragna/_ui/api_wrapper.py Outdated Show resolved Hide resolved
ragna/_ui/main_page.py Outdated Show resolved Hide resolved
Copy link
Member

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment for simplification, but we can do that in a follow-up PR. Thanks Pierre!

Comment on lines +85 to +86
async def get_components(self):
return (await self.client.get("/components")).raise_for_status().json()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that in a follow-up, but we shouldn't need this anymore, right? We could just set this as an instance variable in __init__ and access it from there. The components will never change at runtime.

@pmeier pmeier merged commit 728b88a into main Nov 1, 2023
9 checks passed
@pmeier pmeier deleted the async_api_wrapper branch November 1, 2023 16:05
@pmeier pmeier mentioned this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants