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

fix(copilot): refresh token before sending the request #791

Merged
merged 2 commits into from
Nov 6, 2024

Conversation

brewinski
Copy link
Contributor

I was occasionally encountering 401 error responses when using the Copilot provider. Upon investigation, I discovered that the chat/complete request was being sent before the token could be refreshed.

To address this issue, I have modified the token refresh call to be synchronous. Additionally, I have used vim.schedule to refresh the token on startup.

@brewinski brewinski force-pushed the fix/copilot-token-expired branch 2 times, most recently from 0f35b3b to 87e3841 Compare November 4, 2024 04:07
@aarnphm aarnphm changed the title fix(copilot-provider) refresh token before sending the request fix(copilot): refresh token before sending the request Nov 4, 2024
Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

few comments

lua/avante/providers/copilot.lua Show resolved Hide resolved
lua/avante/providers/copilot.lua Show resolved Hide resolved
@brewinski
Copy link
Contributor Author

brewinski commented Nov 4, 2024

few comments

Thanks for taking the time to review @aarnphm. I've responded and look forward to any advice you have for improving this PR.

@brewinski
Copy link
Contributor Author

@aarnphm I've updated the response status logic. Thanks again for spending your time looking into this, please let me know if you need any further changes or updates from me.

…red token errors.

fix(copilot) update and save copilot token when the response is 200

fix(copilot) update refresh token on editor startup
Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

lgtm thanks

@aarnphm aarnphm merged commit c516883 into yetone:main Nov 6, 2024
2 checks passed
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.

3 participants