Skip to content

Modify answer_question function to pass response through gpt_response - #7

Open
repodex-app[bot] wants to merge 1 commit into
masterfrom
changes_1691449650
Open

Modify answer_question function to pass response through gpt_response#7
repodex-app[bot] wants to merge 1 commit into
masterfrom
changes_1691449650

Conversation

@repodex-app

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

Copy link
Copy Markdown

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