-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinit.py
35 lines (24 loc) · 1003 Bytes
/
init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import sys
sys.path.append("Core")
from concurrent.futures.thread import ThreadPoolExecutor
from tortoise import Tortoise
from Common.Config import config
import agentscope
async def init_db():
# Here we create a SQLite DB using file "db.sqlite3"
# also specify the app name of "models"
# which contain models from "app.models"
await Tortoise.init(
db_url='sqlite://{}/App-Controller.sqlite3'.format(os.path.join(config.app_data_dir, "UserData")),
modules={'models': ["Database.Models.SessionModel"]}
)
# Generate the schema
await Tortoise.generate_schemas()
async def init_server(app):
await init_db()
async def close_server(app):
await Tortoise.close_connections()
agentscope.init(save_dir=os.path.join(config.app_data_dir, "runs/Ignore"), save_log=False, save_code=False, save_api_invoke=False,
use_monitor=False)
model_response_thread_pool = ThreadPoolExecutor(max_workers=config.model_response_thread_size)