mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-10-18 14:20:39 +08:00
Fix unittests, use Union typing
This commit is contained in:
@@ -35,13 +35,15 @@ class TestPassModel(unittest.TestCase):
|
||||
response = client.chat.completions.create(messages, "Hello", stream=True)
|
||||
for chunk in response:
|
||||
self.assertIsInstance(chunk, ChatCompletionChunk)
|
||||
self.assertIsInstance(chunk.choices[0].delta.content, str)
|
||||
if chunk.choices[0].delta.content is not None:
|
||||
self.assertIsInstance(chunk.choices[0].delta.content, str)
|
||||
messages = [{'role': 'user', 'content': chunk} for chunk in ["You ", "You ", "Other", "?"]]
|
||||
response = client.chat.completions.create(messages, "Hello", stream=True, max_tokens=2)
|
||||
response = list(response)
|
||||
self.assertEqual(len(response), 2)
|
||||
self.assertEqual(len(response), 3)
|
||||
for chunk in response:
|
||||
self.assertEqual(chunk.choices[0].delta.content, "You ")
|
||||
if chunk.choices[0].delta.content is not None:
|
||||
self.assertEqual(chunk.choices[0].delta.content, "You ")
|
||||
|
||||
def test_stop(self):
|
||||
client = Client(provider=YieldProviderMock)
|
||||
|
Reference in New Issue
Block a user