XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Refactor async tests for chat completions (etc/unittest/async_client.py)

6a2e83c6
kqlio67 <kqlio67@users.noreply.github.com>
提交于

代码差异

1 个文件 +3 -3
Modified etc/unittest/async_client.py +3 -3
@@ -32,13 +32,13 @@ class AsyncTestPassModel(unittest.IsolatedAsyncioTestCase):
32 32 async def test_max_stream(self):
33 33 client = AsyncClient(provider=YieldProviderMock)
34 34 messages = [{'role': 'user', 'content': chunk} for chunk in ["How ", "are ", "you", "?"]]
35 response = client.chat.completions.create(messages, "Hello", stream=True)
35 response = await client.chat.completions.create(messages, "Hello", stream=True)
36 36 async for chunk in response:
37 37 self.assertIsInstance(chunk, ChatCompletionChunk)
38 38 if chunk.choices[0].delta.content is not None:
39 39 self.assertIsInstance(chunk.choices[0].delta.content, str)
40 40 messages = [{'role': 'user', 'content': chunk} for chunk in ["You ", "You ", "Other", "?"]]
41 response = client.chat.completions.create(messages, "Hello", stream=True, max_tokens=2)
41 response = await client.chat.completions.create(messages, "Hello", stream=True, max_tokens=2)
42 42 response = [chunk async for chunk in response]
43 43 self.assertEqual(len(response), 3)
44 44 for chunk in response:
@@ -53,4 +53,4 @@ class AsyncTestPassModel(unittest.IsolatedAsyncioTestCase):
53 53 self.assertEqual("How are you?", response.choices[0].message.content)
54 54
55 55 if __name__ == '__main__':
56 unittest.main()
56 unittest.main()