mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-27 17:56:23 +02:00
rename example file and add more logs. add ping.py
This commit is contained in:
parent
e212e7b7b9
commit
cc0412b70d
2 changed files with 45 additions and 13 deletions
29
examples/ping.py
Normal file
29
examples/ping.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2024/4/22 14:28
|
||||
@Author : alexanderwu
|
||||
@File : ping.py
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.logs import logger
|
||||
|
||||
|
||||
async def ask_and_print(question: str, llm: LLM, system_prompt) -> str:
|
||||
logger.info(f"Q: {question}")
|
||||
rsp = await llm.aask(question, system_msgs=[system_prompt])
|
||||
logger.info(f"A: {rsp}")
|
||||
logger.info("\n")
|
||||
return rsp
|
||||
|
||||
|
||||
async def main():
|
||||
llm = LLM()
|
||||
await ask_and_print("ping?", llm, "Just answer pong when ping.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue