add new test for aask_code about write code by steps.

This commit is contained in:
刘棒棒 2023-12-20 19:56:26 +08:00
parent 1145641cdc
commit 5af4f6b4c5

View file

@ -78,3 +78,17 @@ def test_ask_code_list_str():
assert "language" in rsp
assert "code" in rsp
assert len(rsp["code"]) > 0
@pytest.mark.asyncio
async def test_ask_code_steps2():
llm = OpenAIGPTAPI()
msg = ["step by setp 生成代码: Step 1. 先生成随机数组a, Step 2. 求a中最大值, Step 3. 绘制数据a的直方图"]
rsp = await llm.aask_code(msg) # -> {'language': 'python', 'code': 'max_value = max(a)\nmax_value'}
print(rsp)
assert "language" in rsp
assert "code" in rsp
assert len(rsp["code"]) > 0
assert "Step 1" in rsp["code"]
assert "Step 2" in rsp["code"]
assert "Step 3" in rsp["code"]