You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import traceback
|
|
import base
|
|
import local
|
|
from service.chat_complete import ChatCompleteService
|
|
from service.database import DatabaseService
|
|
|
|
from service.tiktoken import TikTokenService
|
|
|
|
async def main():
|
|
dbs = await DatabaseService.create()
|
|
tiktoken = await TikTokenService.create()
|
|
|
|
async with ChatCompleteService(dbs, "代号:曙光的世界/黄昏的阿瓦隆") as chat_complete:
|
|
question = "你是谁?"
|
|
question_tokens = await tiktoken.get_tokens(question)
|
|
|
|
try:
|
|
prepare_res = await chat_complete.prepare_chat_complete(question, None, 1, question_tokens, {
|
|
"distance_limit": 0.6,
|
|
"limit": 10
|
|
})
|
|
|
|
print(prepare_res)
|
|
async def on_message(message: str):
|
|
# print(message)
|
|
pass
|
|
|
|
res = await chat_complete.finish_chat_complete(on_message)
|
|
print(res)
|
|
except Exception as err:
|
|
print(err)
|
|
traceback.print_exc()
|
|
|
|
await local.noawait.end()
|
|
|
|
if __name__ == '__main__':
|
|
local.loop.run_until_complete(main()) |