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 a query optimization class #99

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dasgoutam
Copy link
Collaborator

A check is performed before query optimzation using an LLM based on the following criteria. If query is "simple", it is not changed.

  1. Length -
    A query length greater than a certain number of characters is deemed complicated (The parameter is currently in the class. Can be moved to settings.py later )

  2. Punctuation -
    Three punctuations are considered (period, comma, question mark) in different languages ( More language support can be added ). If the query contains multiple sentences(more than 1 period), multiple commas or question marks, it is deemed to be complicated

@dasgoutam dasgoutam requested a review from svenseeberg December 9, 2024 13:42
@dasgoutam
Copy link
Collaborator Author

Example optimization -

  1. "How do I learn German? " remains as it is
Screenshot 2024-12-09 at 2 46 47 PM
  1. "How do I learn German. I am an American born in Egypt. I want to learn the language" is changed as it contains multiple sentences
Screenshot 2024-12-09 at 2 47 16 PM

)
else:
message = data["message"]

answer_service = AnswerService(data["region"], rag_language)
if answer_service.needs_answer(data["message"]):
if settings.RAG_QUERY_OPTIMIZATION:
message = answer_service.optimize_query_for_retrieval(message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the optimize_query_for_retrieval() is not needed anymore, we can directly remove it from the AnswerService?

Copy link
Member

@svenseeberg svenseeberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks 🚀

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