Skip to content

Commit

Permalink
Remove user id from question in SlackChatApp class
Browse files Browse the repository at this point in the history
  • Loading branch information
StanGirard committed Apr 21, 2024
1 parent ce6f8b6 commit d6c6fb4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,10 @@ def ask_question(self, body, brain_id, thread_ts, question=None):
if brain_id == "00000000-0000-0000-0000-000000000000":
brain_id = None
params = {"brain_id": brain_id}
# Example message to remove: @U06V65Z7W4D What is quivr ? . Remove the user id @U06V65Z7W4D. Use a regex to match the user id that always starts with @ and followed by 9 characters.
clean_question_without_id = re.sub(r"@[\w\d]{9}", "", question)
question_data = {
"question": question,
"question": clean_question_without_id,
}
question_response = self.make_quivr_api_request(
"POST", f"/chat/{chat_id}/question", data=question_data, params=params
Expand Down Expand Up @@ -395,8 +397,9 @@ def handle_iteractive_request(self, payload):
if brain_id == "00000000-0000-0000-0000-000000000000":
brain_id = None
params = {"brain_id": brain_id}
clean_question_without_id = re.sub(r"@[\w\d]{9}", "", question)
question_data = {
"question": question,
"question": clean_question_without_id,
}
question_response = self.make_quivr_api_request(
"POST", f"/chat/{chat_id}/question", data=question_data, params=params
Expand Down

0 comments on commit d6c6fb4

Please sign in to comment.