Skip to content

Commit

Permalink
change watchbot.chech_dialog to watchbot.verify (consistent with readme)
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Calcavecchia committed May 26, 2023
1 parent fd2f429 commit 9e8552c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/watch_bot/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, engine: str, chatbot_instructions: str) -> None:
self._engine = engine
self._chatbot_instructions = chatbot_instructions

def check_dialog(self, dialog: Dialog) -> WatchBotResponse:
def verify(self, dialog: Dialog) -> WatchBotResponse:
answer = self._ask_gpt_if_dialog_is_suspicious(dialog=dialog)
if "yes" in answer[:5].lower():
return WatchBotResponse(should_stop=True, reason=answer)
Expand Down
8 changes: 4 additions & 4 deletions test/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def setUp(self) -> None:
openai.api_base = os.environ["OPENAI_API_BASE"]
openai.api_key = os.environ["OPENAI_API_KEY"]

def test_instance_with_defaults_has_check_dialog_method(self) -> None:
self.assertTrue(hasattr(self.bot, "check_dialog"))
def test_instance_with_defaults_has_verify_method(self) -> None:
self.assertTrue(hasattr(self.bot, "verify"))

def test_build_prompt(self) -> None:
self.assertTrue(
Expand All @@ -34,12 +34,12 @@ def test_build_prompt_when_messages_contain_double_quotation_mark(self) -> None:

def test_check_regular_dialog_returns_should_not_stop(self) -> None:
dialog = Dialog(messages=["Hi", "Hello"])
response = self.bot.check_dialog(dialog=dialog)
response = self.bot.verify(dialog=dialog)
self.assertFalse(response.should_stop)
self.assertEqual(len(response.reason), 0)

def test_check_dialog_with_hack_attack_returns_should_not_stop(self) -> None:
dialog = Dialog(messages=[read_hack_prompt(), read_hack_prompt_answer()])
response = self.bot.check_dialog(dialog=dialog)
response = self.bot.verify(dialog=dialog)
self.assertTrue(response.should_stop)
self.assertGreater(len(response.reason), 0)

0 comments on commit 9e8552c

Please sign in to comment.