File size: 782 Bytes
fadcd11
 
 
 
eb474ee
fadcd11
 
 
 
 
 
 
eb474ee
fadcd11
 
 
 
eb474ee
 
 
 
 
 
 
 
 
 
 
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
import os
from beanie import init_beanie
from motor.motor_asyncio import AsyncIOMotorClient

from src.models import User, Session, File, VectorStoreRecordId, Conversation, Message


class DatabaseConfig:
    def __init__(self):

        self.MONGO_URI = os.getenv("MONGO_DB_URI")
        self.MONGO_DB_NAME = os.getenv("MONGO_DB_NAME")
        self.client = AsyncIOMotorClient(self.MONGO_URI, uuidRepresentation="standard")
        self.db = self.client[self.MONGO_DB_NAME]

    async def init_beanie(self):

        await init_beanie(
            database=self.db,
            document_models=[
                User,
                Session,
                Conversation,
                Message,
                File,
                VectorStoreRecordId,
            ],
        )