feat: +log

This commit is contained in:
莘权 马 2023-12-04 10:31:02 +08:00
parent 739348e8f1
commit 4845dafb94
2 changed files with 11 additions and 0 deletions

View file

@ -15,6 +15,7 @@ from metagpt.logs import logger
class TestGPT:
def test_llm_api_ask(self, llm_api):
answer = llm_api.ask("hello chatgpt")
logger.info(answer)
assert len(answer) > 0
# def test_gptapi_ask_batch(self, llm_api):
@ -23,16 +24,19 @@ class TestGPT:
def test_llm_api_ask_code(self, llm_api):
answer = llm_api.ask_code(["请扮演一个Google Python专家工程师如果理解回复明白", "写一个hello world"])
logger.info(answer)
assert len(answer) > 0
@pytest.mark.asyncio
async def test_llm_api_aask(self, llm_api):
answer = await llm_api.aask("hello chatgpt")
logger.info(answer)
assert len(answer) > 0
@pytest.mark.asyncio
async def test_llm_api_aask_code(self, llm_api):
answer = await llm_api.aask_code(["请扮演一个Google Python专家工程师如果理解回复明白", "写一个hello world"])
logger.info(answer)
assert len(answer) > 0
@pytest.mark.asyncio
@ -41,3 +45,7 @@ class TestGPT:
costs = llm_api.get_costs()
logger.info(costs)
assert costs.total_cost > 0
# if __name__ == "__main__":
# pytest.main([__file__, "-s"])

View file

@ -32,3 +32,6 @@ async def test_llm_acompletion(llm):
assert len(await llm.acompletion(hello_msg)) > 0
assert len(await llm.acompletion_batch([hello_msg])) > 0
assert len(await llm.acompletion_batch_text([hello_msg])) > 0
# if __name__ == "__main__":
# pytest.main([__file__, "-s"])