-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (24 loc) · 991 Bytes
/
main.py
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
import os
from fastapi import FastAPI
from dependencies import initialize_text_embedding
from routes.embeddings import embeddings_router
from routes.memory import memory_router
from routes.root import root_router
# Initializing FastAPI application with title, version, description and base server URL
app = FastAPI(
title="AI Memory API",
version="0.1.0",
description="A FastAPI application that allows users to save memories ...",
root_path=os.getenv("ROOT_PATH", ""),
servers=[{"url": os.getenv("BASE_URL", ""), "description": "Base API server"}],
)
@app.on_event("startup")
async def startup_event():
# Initialize the text embedding singleton
await initialize_text_embedding()
# Including Routers for different endpoints
app.include_router(memory_router)
app.include_router(root_router)
# Conditionally include the root_router based on EMBEDDING_ENDPOINT env var
if os.getenv("EMBEDDING_ENDPOINT") == "true":
app.include_router(embeddings_router)