能跑但是没写部署教程,主题和记忆识别也没写完
This commit is contained in:
SengokuCola
2025-02-26 18:12:28 +08:00
parent 44f94120ce
commit 972e6066e6
37 changed files with 4625 additions and 0 deletions

1
src/common/__init__.py Normal file
View File

@@ -0,0 +1 @@
# 这个文件可以为空,但必须存在

21
src/common/database.py Normal file
View File

@@ -0,0 +1,21 @@
from pymongo import MongoClient
from typing import Optional
class Database:
_instance: Optional["Database"] = None
def __init__(self, host: str, port: int, db_name: str):
self.client = MongoClient(host, port)
self.db = self.client[db_name]
@classmethod
def initialize(cls, host: str, port: int, db_name: str) -> "Database":
if cls._instance is None:
cls._instance = cls(host, port, db_name)
return cls._instance
@classmethod
def get_instance(cls) -> "Database":
if cls._instance is None:
raise RuntimeError("Database not initialized")
return cls._instance