diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-01-23 12:18:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 12:18:32 +0100 |
commit | 984c3e1f891b1242954413d7abf81d0a45aa1110 (patch) | |
tree | 1f1bee0d403b70866b2bf5f71cfc5a0fb2fe4efd /etc/unittest/model.py | |
parent | Added CodeLlama and misc models from DeepInfra (#1506) (diff) | |
parent | Fix: Model sometimes not converted #1507 (diff) | |
download | gpt4free-984c3e1f891b1242954413d7abf81d0a45aa1110.tar gpt4free-984c3e1f891b1242954413d7abf81d0a45aa1110.tar.gz gpt4free-984c3e1f891b1242954413d7abf81d0a45aa1110.tar.bz2 gpt4free-984c3e1f891b1242954413d7abf81d0a45aa1110.tar.lz gpt4free-984c3e1f891b1242954413d7abf81d0a45aa1110.tar.xz gpt4free-984c3e1f891b1242954413d7abf81d0a45aa1110.tar.zst gpt4free-984c3e1f891b1242954413d7abf81d0a45aa1110.zip |
Diffstat (limited to 'etc/unittest/model.py')
-rw-r--r-- | etc/unittest/model.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/etc/unittest/model.py b/etc/unittest/model.py new file mode 100644 index 00000000..0d318e7a --- /dev/null +++ b/etc/unittest/model.py @@ -0,0 +1,27 @@ +import unittest +import g4f +from g4f import ChatCompletion +from .mocks import ModelProviderMock + +DEFAULT_MESSAGES = [{'role': 'user', 'content': 'Hello'}] + +test_model = g4f.models.Model( + name = "test/test_model", + base_provider = "", + best_provider = ModelProviderMock +) +g4f.models.ModelUtils.convert["test_model"] = test_model + +class TestPassModel(unittest.TestCase): + + def test_model_instance(self): + response = ChatCompletion.create(test_model, DEFAULT_MESSAGES) + self.assertEqual(test_model.name, response) + + def test_model_name(self): + response = ChatCompletion.create("test_model", DEFAULT_MESSAGES) + self.assertEqual(test_model.name, response) + + def test_model_pass(self): + response = ChatCompletion.create("test/test_model", DEFAULT_MESSAGES, ModelProviderMock) + self.assertEqual(test_model.name, response)
\ No newline at end of file |