forked from geekan/MetaGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
肖凌风
committed
Jul 21, 2023
1 parent
8c07be0
commit 227c837
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
@Time : 2023/5/6 14:13 | ||
@Author : alexanderwu | ||
@File : llm_hello_world.py | ||
""" | ||
import asyncio | ||
|
||
from metagpt.logs import logger | ||
from metagpt.llm import LLM | ||
from metagpt.llm import Claude | ||
|
||
async def main(): | ||
llm = LLM() | ||
claude = Claude() | ||
logger.info(await claude.aask('你好,请进行自我介绍')) | ||
logger.info(await llm.aask('hello world')) | ||
logger.info(await llm.aask_batch(['hi', 'write python hello world.'])) | ||
|
||
hello_msg = [{'role': 'user', 'content': 'count from 1 to 10. split by newline.'}] | ||
logger.info(await llm.acompletion(hello_msg)) | ||
logger.info(await llm.acompletion_batch([hello_msg])) | ||
logger.info(await llm.acompletion_batch_text([hello_msg])) | ||
|
||
logger.info(await llm.acompletion_text(hello_msg)) | ||
await llm.acompletion_text(hello_msg, stream=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters