zakcroft / RAG-chatbot-python-server

0 stars 0 forks source link

Sweep: Make an api endpoint for delete_conversation_history in app.py #4

Open zakcroft opened 1 year ago

zakcroft commented 1 year ago
Checklist - [X] `chat_store/db.py` > • Add a new function named `db_delete_conversation`. This function should take a `conversation_key` as an argument. > • Inside this function, get the Redis instance by calling the `get_redis` function. > • Use the `delete` method of the Redis instance to delete the conversation history associated with the `conversation_key`. > • Return a success message if the deletion is successful, or an error message if the conversation history does not exist. - [X] `api.py` > • Import the `db_delete_conversation` function from `chat_store/db.py`. > • Add a new API endpoint named `/delete-conversation-history/{key}`. This endpoint should be a DELETE request that takes a `key` as a parameter. > • Inside this endpoint, call the `db_delete_conversation` function with the `key` as an argument. > • Return the result of the `db_delete_conversation` function.
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/zakcroft/RAG-chatbot-python-server/pull/5.

⚡ Sweep Free Trial: I used GPT-3.5 to create this ticket. You have 4 GPT-4 tickets left for the month and 0 for the day. For more GPT-4 tickets, visit our payment portal. To retrigger Sweep, edit the issue.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/zakcroft/RAG-chatbot-python-server/blob/88bf9d7262c43a45953dd15791ab9203ecc9e933/api.py#L1-L148 https://github.com/zakcroft/RAG-chatbot-python-server/blob/88bf9d7262c43a45953dd15791ab9203ecc9e933/open_ai.py#L1-L55 https://github.com/zakcroft/RAG-chatbot-python-server/blob/88bf9d7262c43a45953dd15791ab9203ecc9e933/chat_store/db.py#L1-L58 https://github.com/zakcroft/RAG-chatbot-python-server/blob/88bf9d7262c43a45953dd15791ab9203ecc9e933/vector_dbs/embed.py#L1-L5 https://github.com/zakcroft/RAG-chatbot-python-server/blob/88bf9d7262c43a45953dd15791ab9203ecc9e933/prompts/qa_prompts.py#L1-L46

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
chat_store/db.py Modify chat_store/db.py with contents:
• Add a new function named db_delete_conversation. This function should take a conversation_key as an argument.
• Inside this function, get the Redis instance by calling the get_redis function.
• Use the delete method of the Redis instance to delete the conversation history associated with the conversation_key.
• Return a success message if the deletion is successful, or an error message if the conversation history does not exist.
api.py Modify api.py with contents:
• Import the db_delete_conversation function from chat_store/db.py.
• Add a new API endpoint named /delete-conversation-history/{key}. This endpoint should be a DELETE request that takes a key as a parameter.
• Inside this endpoint, call the db_delete_conversation function with the key as an argument.
• Return the result of the db_delete_conversation function.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Add API endpoint for deleting conversation history sweep/delete-conversation-history

Description

This PR adds a new API endpoint /delete-conversation-history/{key} that allows for the deletion of a conversation history from the Redis database. It also includes the necessary changes in the chat_store/db.py file to implement the deletion functionality.

Summary of Changes

  • Added a new function db_delete_conversation in chat_store/db.py that deletes a conversation history from the Redis database.
  • Created a new API endpoint /delete-conversation-history/{key} in api.py that calls the db_delete_conversation function.
  • The API endpoint is a DELETE request that takes a key parameter representing the conversation key.
  • The db_delete_conversation function retrieves the Redis instance, deletes the conversation history associated with the key, and returns a success message or an error message if the conversation history does not exist.

Please review and merge this PR. Thank you!


Step 4: ⌨️ Coding

File Instructions Progress
chat_store/db.py Modify chat_store/db.py with contents:
• Add a new function named db_delete_conversation. This function should take a conversation_key as an argument.
• Inside this function, get the Redis instance by calling the get_redis function.
• Use the delete method of the Redis instance to delete the conversation history associated with the conversation_key.
• Return a success message if the deletion is successful, or an error message if the conversation history does not exist.
✅ Commit 8769244
api.py Modify api.py with contents:
• Import the db_delete_conversation function from chat_store/db.py.
• Add a new API endpoint named /delete-conversation-history/{key}. This endpoint should be a DELETE request that takes a key as a parameter.
• Inside this endpoint, call the db_delete_conversation function with the key as an argument.
• Return the result of the db_delete_conversation function.
✅ Commit 8769244 I have finished coding the issue. I am now reviewing it for completeness.

Step 5: 🔁 Code Review

Here are my self-reviews of my changes at sweep/delete-conversation-history.

Here is the 1st review

The changes made in the api.py and chat_store/db.py files look good. The new endpoint for deleting conversation history and the corresponding function in the database module seem to be correctly implemented.

However, please ensure that the get_redis function is correctly implemented and handles all possible edge cases, such as when the Redis instance is not available.

Great job on this! Keep up the good work.

I finished incorporating these changes.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. Join Our Discord