from fastapi import FastAPI

from vdash.config import Settings
from vdash.core import Database, run_migrations
from vdash.modules.llm import BaseLlm


class Vdash:
    def __init__(self, llm: BaseLlm, settings: Settings):
        self.settings = settings
        self.db = Database(self.settings)
        self.llm: BaseLlm = llm

        if self.settings.run_migrations:
            run_migrations(self.settings.db_url)

    def create_app(self) -> FastAPI:
        from vdash.presentation.api import create_fastapi

        return create_fastapi(settings=self.settings, db=self.db, llm=self.llm)
