File size: 1,313 Bytes
5a67683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
import logging

from fastapi import FastAPI

from app._config import settings
from app.components.embedding.component import EmbeddingComponent
from app.components.llm.component import LLMComponent
from app.components.node_store.component import NodeStoreComponent
from app.components.vector_store.component import VectorStoreComponent
from app.server.chat.router import chat_router
from app.server.chat.service import ChatService
from app.server.embedding.router import embedding_router
from app.server.ingest.service import IngestService

logger = logging.getLogger(__name__)

app = FastAPI()
app.include_router(chat_router)
app.include_router(embedding_router)

if settings.IS_UI_ENABLED:
    logger.debug("Importing the UI module")
    from app.ui.ui import PrivateGptUi

    llm_component = LLMComponent()
    vector_store_component = VectorStoreComponent()
    embedding_component = EmbeddingComponent()
    node_store_component = NodeStoreComponent()

    ingest_service = IngestService(
        llm_component, vector_store_component, embedding_component, node_store_component
    )
    chat_service = ChatService(
        llm_component, vector_store_component, embedding_component, node_store_component
    )

    ui = PrivateGptUi(ingest_service, chat_service)
    ui.mount_in_app(app, settings.UI_PATH)