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

refactor: chat_routes #1512

Merged
merged 9 commits into from
Oct 30, 2023
Merged

refactor: chat_routes #1512

merged 9 commits into from
Oct 30, 2023

Conversation

gozineb
Copy link
Contributor

@gozineb gozineb commented Oct 27, 2023

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Checklist before requesting a review

Please delete options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented hard-to-understand areas
  • I have ideally added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Screenshots (if appropriate):

@gozineb gozineb temporarily deployed to preview October 27, 2023 07:53 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Oct 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 27, 2023 7:56am
quivr-strapi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 27, 2023 7:56am
quivrapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 27, 2023 7:56am

@dosubot dosubot bot added the area: backend Related to backend functionality or under the /backend directory label Oct 27, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2023

Risk Level 2 - /home/runner/work/quivr/quivr/backend/routes/chat/utils.py

The check_user_requests_limit function raises an HTTPException directly. It would be better to raise a custom exception and handle it at a higher level where you have the context of the request. This would make the code more modular and easier to test.


Risk Level 2 - /home/runner/work/quivr/quivr/backend/routes/chat/brainless_chat.py

The get_openai_api_key method returns the OpenAI API key directly. This could potentially lead to security issues if not handled properly. Make sure that this key is not logged or exposed in any responses.


Risk Level 3 - /home/runner/work/quivr/quivr/backend/routes/chat/chat_routes.py

The create_question_handler and create_stream_question_handler methods are quite long and complex. Consider breaking them down into smaller, more manageable functions. Also, the OpenAI API key is being retrieved from the request headers and assigned to the current_user object. This could potentially lead to security issues if not handled properly. Make sure that this key is not logged or exposed in any responses.


🔐🔧📏


Powered by Code Review GPT

@mamadoudicko
Copy link
Contributor

Thanks Zineb 😍!

from routes.chat.interface import ChatInterface


class BrainfulChat(ChatInterface):
def validate_authorization(self, user_id, brain_id):
pass
if brain_id:

Choose a reason for hiding this comment

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

le if ici n'est plus nécessaire car tu fais déjà le if dans la factory

def get_chat_strategy(brain_id: UUID | None = None):
if brain_id:
return BrainfulChat()
else:

Choose a reason for hiding this comment

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

Le else n'est pas nécessaire ici

@gozineb gozineb merged commit e3a99d1 into main Oct 30, 2023
10 of 12 checks passed
mamadoudicko pushed a commit that referenced this pull request Oct 31, 2023
🤖 I have created a release *beep* *boop*
---


## 0.0.100 (2023-10-30)

## What's Changed
* refactor: fix bad smells by @gozineb in
#1399
* refactor: chat_routes by @gozineb in
#1512
* feat: improve ux by @mamadoudicko in
#1522
* feat(docs): reworked the website by @StanGirard in
#1523
* Feat/docs rework by @StanGirard in
#1525


**Full Changelog**:
v0.0.99...v0.0.100

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
coolCatalyst added a commit to coolCatalyst/quivr that referenced this pull request Jun 1, 2024
🤖 I have created a release *beep* *boop*
---


## 0.0.100 (2023-10-30)

## What's Changed
* refactor: fix bad smells by @gozineb in
QuivrHQ/quivr#1399
* refactor: chat_routes by @gozineb in
QuivrHQ/quivr#1512
* feat: improve ux by @mamadoudicko in
QuivrHQ/quivr#1522
* feat(docs): reworked the website by @StanGirard in
QuivrHQ/quivr#1523
* Feat/docs rework by @StanGirard in
QuivrHQ/quivr#1525


**Full Changelog**:
QuivrHQ/quivr@v0.0.99...v0.0.100

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: backend Related to backend functionality or under the /backend directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants