Skip to content

Commit cc8158e

Browse files
committed
add 'init_chroma_db'
1 parent c2a5858 commit cc8158e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

create_sqlite_db.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,25 @@
66
from werkzeug.security import generate_password_hash
77
from server.app.utils.diskcache_client import diskcache_client
88
from server.constant.constants import SQLITE_DB_DIR, SQLITE_DB_NAME
9+
from dotenv import load_dotenv
910

1011

1112
os.makedirs(SQLITE_DB_DIR, exist_ok=True)
1213

1314

15+
def init_chroma_db():
16+
# Load environment variables from .env file
17+
load_dotenv(override=True)
18+
try:
19+
from server.constant.env_constants import check_env_variables
20+
check_env_variables()
21+
from server.rag.index.embedder.document_embedder import document_embedder
22+
return True
23+
except Exception as e:
24+
print(f"[ERROR] init_chroma_db is failed, the exception is {e}")
25+
return False
26+
27+
1428
def create_table():
1529
conn = sqlite3.connect(f'{SQLITE_DB_DIR}/{SQLITE_DB_NAME}')
1630
cur = conn.cursor()
@@ -323,6 +337,12 @@ def init_bot_setting():
323337
init_admin_account()
324338
print('Initialize the bot settings')
325339
init_bot_setting()
340+
print('SQLite init Done!\n\n')
326341

327-
print('Done!')
328342

343+
print("Init Chroma DB")
344+
ret = init_chroma_db()
345+
if ret:
346+
print("Init Chroma DB Done!")
347+
else:
348+
print("Init Chroma DB Failed!")

0 commit comments

Comments
 (0)