From 0b712c2bde77fe7e3e347d71d5de3c9e62f26738 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Fri, 12 Apr 2024 18:01:54 +0200 Subject: Add unittests for async client (#1830) * Add unittests for async client * Add pollyfill for anext * Update integration tests --- etc/unittest/integration.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'etc/unittest/integration.py') diff --git a/etc/unittest/integration.py b/etc/unittest/integration.py index f69d4770..d87a7f6b 100644 --- a/etc/unittest/integration.py +++ b/etc/unittest/integration.py @@ -8,7 +8,7 @@ except ImportError: has_nest_asyncio = False from g4f.client import Client, ChatCompletion -from g4f.Provider import Bing, OpenaiChat +from g4f.Provider import Bing, OpenaiChat, DuckDuckGo DEFAULT_MESSAGES = [{"role": "system", "content": 'Response in json, Example: {"success: true"}'}, {"role": "user", "content": "Say success true in json"}] @@ -19,11 +19,19 @@ class TestProviderIntegration(unittest.TestCase): self.skipTest("nest_asyncio is not installed") def test_bing(self): + self.skipTest("Not stable") client = Client(provider=Bing) response = client.chat.completions.create(DEFAULT_MESSAGES, "", response_format={"type": "json_object"}) self.assertIsInstance(response, ChatCompletion) self.assertIn("success", json.loads(response.choices[0].message.content)) + def test_duckduckgo(self): + self.skipTest("Not working") + client = Client(provider=DuckDuckGo) + response = client.chat.completions.create(DEFAULT_MESSAGES, "", response_format={"type": "json_object"}) + self.assertIsInstance(response, ChatCompletion) + self.assertIn("success", json.loads(response.choices[0].message.content)) + def test_openai(self): client = Client(provider=OpenaiChat) response = client.chat.completions.create(DEFAULT_MESSAGES, "", response_format={"type": "json_object"}) -- cgit v1.2.3