|
|
|
|
|
""" |
|
@File : search_kb.py |
|
@Modified By: mashenquan, 2023-8-9, fix-bug: cannot find metagpt module. |
|
""" |
|
import asyncio |
|
from pathlib import Path |
|
import sys |
|
sys.path.append(str(Path(__file__).resolve().parent.parent)) |
|
from metagpt.const import DATA_PATH |
|
from metagpt.document_store import FaissStore |
|
from metagpt.logs import logger |
|
from metagpt.roles import Sales |
|
|
|
|
|
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()) |
|
|