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

Modify answer_question function to pass response through gpt_response #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

repodex-app[bot]
Copy link

@repodex-app repodex-app bot commented Aug 7, 2023

Title: Improve Response Generation with GPT Rephrasing

Summary

This pull request modifies the answer_question function to improve the quality of the generated responses by utilizing the gpt_response function from code_analysis.utils.gpt_response. The changes ensure that the responses are passed through the GPT rephrasing function before being returned to the user.

Changes Made

  1. Imported the gpt_response function from code_analysis.utils.gpt_response.
  2. Modified the answer_question function to pass the response through the gpt_response function with the format 'rephrase this: ' + answer.
  3. Ensured that the modified response is returned to the user.

Old Code

def answer_question(self, answer, text):
    if answer['score'] > self.settings['min_score']:
        print "\nBest-fit question: %s (Score: %s)\nAnswer: %s\n" % (answer['question'],
                                                                      answer['score'],
                                                                      answer['answer'])
    else:
        print "Woops! I'm having trouble finding the answer to your question. " \
              "Would you like to see the list of questions that I am able to answer?\n"
        self.event_stack.append(Event("corpus_dump", text))

New Code

def answer_question(self, answer, text):
    if answer['score'] > self.settings['min_score']:
        response = "\nBest-fit question: %s (Score: %s)\nAnswer: %s\n" % (answer['question'],
                                                                          answer['score'],
                                                                          answer['answer'])
        print(gpt_response('rephrase this: ' + response))
    else:
        response = "Woops! I'm having trouble finding the answer to your question. " \
                  "Would you like to see the list of questions that I am able to answer?\n"
        print(gpt_response('rephrase this: ' + response))
        self.event_stack.append(Event("corpus_dump", text))

Impact

These changes will improve the quality of the generated responses by rephrasing them using the GPT model, making them more helpful and user-friendly.

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.

0 participants