INNER CODE UNIT · Python

lifespan

pathwaycom/llm-app · serviette/server/main.py:212

    async def lifespan(_: FastAPI):
        # Local embedders (sentence-transformers) lazily import torch and
        # load weights on first use — seconds the first user question must
        # not pay. Warm them up with an invisible query before serving;
        # API embedders skip this (a warm-up there costs real tokens).
        if getattr(embedder, "is_local", False):
            import time as _time

            started = _time.monotonic()
            logger.info(
                "warming up the local embedder (importing the ML stack and "
                "loading the model — the port opens once this is done)..."
            )
            await embedder.embed("serviette warmup")
            logger.info(
                "embedder ready in %.1fs", _time.monotonic() - started
            )
        if reranker is not None and getattr(reranker, "is_local", False):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…