Spaces:
Sleeping
Sleeping
| from unittest import TestCase | |
| import openai | |
| from osbot_utils.utils.Dev import pprint | |
| from osbot_utils.utils.Files import file_exists, file_contents | |
| from osbot_utils.utils.Misc import list_set | |
| from cbr_athena.api.Chat_Predict import Chat_Predict | |
| class test_Chat_Predict(TestCase): | |
| def setUp(self) -> None: | |
| self.chat_predict = Chat_Predict() | |
| def test___init__(self): | |
| assert self.chat_predict.last_response is None | |
| assert self.chat_predict.last_response is None | |
| assert openai.api_key is not None | |
| def test_default_prompt(self): | |
| default_prompt = self.chat_predict.default_prompt() | |
| prompt_role = default_prompt.get('role') | |
| prompt_content = default_prompt.get('content') | |
| assert list_set(default_prompt) == ['content', 'role'] | |
| assert prompt_role == 'system' | |
| assert prompt_content.startswith('\nYou are') | |
| assert prompt_content == file_contents( self.path_file__default_prompt()) | |
| def test_path_file__default_prompt(self): | |
| file_path = self.chat_predict.path_file__default_prompt() | |
| assert file_exists(file_path) | |
| assert "Athena" in file_contents(file_path) | |