mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-27 14:25:20 +02:00
init project
This commit is contained in:
commit
c871144507
204 changed files with 7220 additions and 0 deletions
20
examples/azure_hello_world.py
Normal file
20
examples/azure_hello_world.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/5/25 16:24
|
||||
@Author : alexanderwu
|
||||
@File : azure_hello_world.py
|
||||
"""
|
||||
from metagpt.logs import logger
|
||||
from metagpt.provider import AzureGPTAPI
|
||||
|
||||
|
||||
def azure_gpt_api():
|
||||
"""Currently, Azure only supports synchronous mode."""
|
||||
api = AzureGPTAPI()
|
||||
logger.info(api.ask('write python hello world.'))
|
||||
logger.info(api.completion([{'role': 'user', 'content': 'hello'}]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
azure_gpt_api()
|
||||
27
examples/llm_hello_world.py
Normal file
27
examples/llm_hello_world.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#!/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
|
||||
|
||||
|
||||
async def main():
|
||||
llm = LLM()
|
||||
|
||||
logger.info(await llm.aask('hello world'))
|
||||
logger.info(await llm.aask_batch(['hi', 'write python hello world.']))
|
||||
|
||||
hello_msg = [{'role': 'user', 'content': 'hello'}]
|
||||
logger.info(await llm.acompletion(hello_msg))
|
||||
logger.info(await llm.acompletion_batch([hello_msg]))
|
||||
logger.info(await llm.acompletion_batch_text([hello_msg]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
19
examples/search_google.py
Normal file
19
examples/search_google.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/5/7 18:32
|
||||
@Author : alexanderwu
|
||||
@File : search_google.py
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from metagpt.config import Config
|
||||
from metagpt.roles import Searcher
|
||||
|
||||
|
||||
async def main():
|
||||
await Searcher().run("What are some good sun protection products?")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
25
examples/search_kb.py
Normal file
25
examples/search_kb.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@File : search_kb.py
|
||||
"""
|
||||
import asyncio
|
||||
from metagpt.const import DATA_PATH
|
||||
from metagpt.document_store import FaissStore
|
||||
from metagpt.roles import Sales
|
||||
from metagpt.logs import logger
|
||||
|
||||
|
||||
async def search():
|
||||
store = FaissStore(DATA_PATH / 'example.json')
|
||||
role = Sales(profile="Sales", store=store)
|
||||
|
||||
queries = ["Which facial cleanser is good for oily skin?", "Is L'Oreal good to use?"]
|
||||
for query in queries:
|
||||
logger.info(f"User: {query}")
|
||||
result = await role.run(query)
|
||||
logger.info(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(search())
|
||||
Loading…
Add table
Add a link
Reference in a new issue