Merge branch 'feature/store' of github.com:logspace-ai/langflow into feature/store
This commit is contained in:
commit
09bd8cb009
1 changed files with 11 additions and 7 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
from contextlib import asynccontextmanager
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
@ -13,12 +14,20 @@ from langflow.services.utils import initialize_services, teardown_services
|
||||||
from langflow.utils.logger import configure
|
from langflow.utils.logger import configure
|
||||||
|
|
||||||
|
|
||||||
|
@asynccontextmanager
|
||||||
|
async def lifespan(app: FastAPI):
|
||||||
|
initialize_services()
|
||||||
|
setup_llm_caching()
|
||||||
|
LangfuseInstance.update()
|
||||||
|
yield
|
||||||
|
teardown_services()
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
"""Create the FastAPI app and include the router."""
|
"""Create the FastAPI app and include the router."""
|
||||||
|
|
||||||
configure()
|
configure()
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI(lifespan=lifespan)
|
||||||
origins = ["*"]
|
origins = ["*"]
|
||||||
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
|
|
@ -43,14 +52,9 @@ def create_app():
|
||||||
def health():
|
def health():
|
||||||
return {"status": "ok"}
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
|
||||||
app.include_router(router)
|
app.include_router(router)
|
||||||
|
|
||||||
app.on_event("startup")(initialize_services)
|
|
||||||
app.on_event("startup")(setup_llm_caching)
|
|
||||||
app.on_event("startup")(LangfuseInstance.update)
|
|
||||||
|
|
||||||
app.on_event("shutdown")(teardown_services)
|
|
||||||
app.on_event("shutdown")(LangfuseInstance.teardown)
|
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue