diff --git a/dev_gpt/options/generate/chains/question_answering.py b/dev_gpt/options/generate/chains/question_answering.py index bd8dabe..34e4795 100644 --- a/dev_gpt/options/generate/chains/question_answering.py +++ b/dev_gpt/options/generate/chains/question_answering.py @@ -19,21 +19,26 @@ def answer_yes_no_question(text, question): question=question, text=text, ) + # count words "yes" and "no" in pros and cons + yes_count = pros_and_cons.lower().count('yes') + no_count = pros_and_cons.lower().count('no') + return yes_count > no_count - return ask_gpt( - question_prompt, - boolean_parser, - text=text, - question=question, - pros_and_cons=pros_and_cons, - ) + # return ask_gpt( + # question_prompt, + # boolean_parser, + # text=text, + # question=question, + # pros_and_cons=pros_and_cons, + # ) pros_and_cons_prompt = '''\ # Context {text} # Question {question} -Note: You must not answer the question. Instead, give up to 5 bullet points (10 words) arguing why the question should be answered with true or false.''' +Note: You must not answer the question. Instead, give up to 5 bullet points (10 words) arguing why the question should be answered with yes or no. \ +Each bullet point ends with either "- yes" or "- no".''' question_prompt = '''\ # Context diff --git a/test/unit/test_yes_no_question.py b/test/unit/test_yes_no_question.py new file mode 100644 index 0000000..e03d5d2 --- /dev/null +++ b/test/unit/test_yes_no_question.py @@ -0,0 +1,21 @@ +import os + +from dev_gpt.apis.gpt import GPTSession +from dev_gpt.options.generate.chains.question_answering import answer_yes_no_question + + +def test_answer_yes_no_question(tmpdir): + os.environ['VERBOSE'] = 'true' + GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo') + assert answer_yes_no_question( + '''\ +Microservice description: +``` +The microservice takes a stock symbol as input and returns a summary of the company's stock performance over the past 30 days, \ +including the average closing price and the company name. \ +The summary is returned as a string. \ +The microservice uses the Yahoo Finance API to fetch the stock data and Python libraries to calculate the average closing price and generate the summary. \ +The request parameter is "stock_symbol" and the response parameter is "summary". +``` +''', 'Does the microservice send requests to an API beside the google_custom_search and gpt_3_5_turbo?' + ) == True \ No newline at end of file