From cb738c93329ca5f7d5d359ae7ea2211bde5a496b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Sun, 30 Apr 2023 18:10:05 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20level=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/gpt.py | 7 ++++--- test/test_generator.py | 14 +++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/apis/gpt.py b/src/apis/gpt.py index 4111386..16a53af 100644 --- a/src/apis/gpt.py +++ b/src/apis/gpt.py @@ -108,6 +108,9 @@ class _GPTConversation: self.messages = messages self.print_stream = print_stream self.print_costs = print_costs + + + def print_messages(self, messages): for i, message in enumerate(messages): if os.environ['VERBOSE'].lower() == 'true': if isinstance(message, SystemMessage): @@ -121,9 +124,7 @@ class _GPTConversation: MassageClass = HumanMessage if role == 'user' else SystemMessage chat_message = MassageClass(content=prompt) self.messages.append(chat_message) - if os.environ['VERBOSE'].lower() == 'true': - color = 'blue' if role == 'user' else 'magenta' - print_colored(role, prompt, color) + self.print_messages(self.messages) if self.print_stream: print_colored('assistant', '', 'green', end='') print('thinking...') diff --git a/test/test_generator.py b/test/test_generator.py index 7a03112..f8a021c 100644 --- a/test/test_generator.py +++ b/test/test_generator.py @@ -38,17 +38,9 @@ def test_generation_level_1(tmpdir): """ os.environ['VERBOSE'] = 'true' generator = Generator( - ''' -Input is a tweet that might contain passive aggressive language like: -'When your coworker microwaves fish in the break room... AGAIN. 🐟🤢 -But hey, at least SOMEONE's enjoying their lunch. #officelife' -The output is a tweet that is not passive aggressive like: -'Hi coworker, -I hope you're having an amazing day! -Just a quick note: sometimes microwaving fish can create an interesting aroma in the break room. 😜 -If you're up for trying different lunch options, that could be a fun way to mix things up. -Enjoy your day! #variety' -''', + '''Input is a tweet that might contain passive aggressive language like: +\'When your coworker microwaves fish in the break room... AGAIN. 🐟🤢 +But hey, at least SOMEONE's enjoying their lunch. #officelife\'''', str(tmpdir) + 'microservice', 'gpt-3.5-turbo' )