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

feat: merge chat history with chat notifications #1127

Merged
merged 5 commits into from
Sep 7, 2023
Merged

Conversation

mamadoudicko
Copy link
Contributor

@mamadoudicko mamadoudicko commented Sep 7, 2023

Screen.Recording.2023-09-07.at.14.58.06.mov

@mamadoudicko mamadoudicko temporarily deployed to preview September 7, 2023 12:53 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Sep 7, 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 Sep 7, 2023 1:27pm
quivrapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 7, 2023 1:27pm

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

Risk Level 2 - /home/runner/work/quivr/quivr/backend/repository/chat/get_chat_history_with_notifications.py

The code changes involve the addition of methods to merge chat history and notifications. The methods are well-written and follow good practices. However, there is a potential risk in the merge_chat_history_and_notifications method. If the chat_history or notifications list is empty, the method will not raise an exception. It might be better to add error handling to inform the user if the lists are empty. For example:

if not chat_history or not notifications:
    raise ValueError(\"Chat history or notifications is empty\")

Risk Level 2 - /home/runner/work/quivr/quivr/frontend/lib/api/chat/chat.ts

  1. The chat_id parameter is added to the crawlWebsiteUrl and uploadFile functions but it's not clear what it's used for. Make sure to add comments explaining its purpose.
  2. The chat_id parameter is optional in the crawlWebsiteUrl and uploadFile functions. Make sure to handle the case when it's undefined.

Example code snippet for the second point:

export const crawlWebsiteUrl = async (
  props: CrawlInputProps,
  axiosInstance: AxiosInstance
): Promise<CrawlResponse> =>
  axiosInstance.post(
    `/crawl?brain_id=${props.brainId}&chat_id=${props.chat_id ?? \"default_chat_id\"}`,
    props.config
  );

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

  1. The Openai-Api-Key is being fetched from the request headers and used directly. This could be a potential security risk if the key is not validated. Always validate and sanitize input from users.
  2. The uploadFile function is quite large and does multiple things. Consider breaking it down into smaller functions for better readability and maintainability.
  3. The chat_id parameter is added to the upload_file function but it's not clear what it's used for. Make sure to add comments explaining its purpose.

Example code snippet for the first point:

openai_api_key = request.headers.get(\"Openai-Api-Key\", None)
if openai_api_key is not None:
    # Validate the API key
    if not validate_api_key(openai_api_key):
        raise ValueError(\"Invalid API key\")

🔒🔧💬


Powered by Code Review GPT

@mamadoudicko
Copy link
Contributor Author

#1116

@gozineb gozineb merged commit 9464707 into main Sep 7, 2023
StanGirard pushed a commit that referenced this pull request Sep 12, 2023
* feat: add chat_id to upload and crawl payload

* feat(chat): return chat_history_with_notifications

* feat: explicit notification status on create

* feat: handle notifications in frontend

* feat: delete chat notifications on chat delete request
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