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

Add Feature detect if user requests to talk to a human #118

Merged
merged 12 commits into from
Jan 29, 2025

Conversation

dasgoutam
Copy link
Collaborator

@dasgoutam dasgoutam commented Jan 5, 2025

Implements #25

@dasgoutam dasgoutam linked an issue Jan 6, 2025 that may be closed by this pull request
@dasgoutam dasgoutam marked this pull request as ready for review January 24, 2025 17:37
@@ -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():
Copy link
Member

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

Copy link
Collaborator Author

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,
        ),
    ]

@svenseeberg svenseeberg merged commit e21f809 into main Jan 29, 2025
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.

Render "Talk to Person" button
2 participants