-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Feature detect if user requests to talk to a human #118
Conversation
ed5a1c1
to
c0fe416
Compare
c42fd10
to
af50674
Compare
@@ -82,26 +90,40 @@ def extract_answer(self) -> RagResponse: | |||
return: a dict containing a response and sources | |||
""" | |||
question = str(self.rag_request) | |||
language_service = LanguageService() | |||
|
|||
if self.detect_request_human(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be useful to move this to the def needs_answer()
method? We can then parallelize those requests based on #184
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-structured the needs_answer()
method to include both human_request check and is_question check
def needs_answer(self, message: str, language_service: LanguageService) -> bool:
LOGGER.debug("Checking if the user requests to talk to a human counselor")
if self.detect_request_human():
LOGGER.debug("User requests human intervention.")
return [
False,
RagResponse(
[],
self.rag_request,
language_service.translate_message(
"en", self.language, Messages.TALK_TO_HUMAN
),
False,
),
]
LOGGER.debug("Checking if user message is a question or intent")
answer = self.llm_api.simple_prompt(Prompts.CHECK_QUESTION.format(message))
if answer.startswith("Yes"):
LOGGER.debug("Message requires response.")
return [True, None]
LOGGER.debug("Message does not require response.")
return [
False,
RagResponse(
[],
self.rag_request,
language_service.translate_message(
"en", self.language, Messages.NOT_QUESTION
),
False,
),
]
Implements #25