INNER CODE UNIT · Python

on_post

tensorchord/modelz-llm · src/modelz_llm/falcon_service.py:86

    async def on_post(self, req: Request, resp: Response, engine: str = ""):
        if engine:
            logger.info("received emb req with engine: %s", engine)

        buf = await req.stream.readall()
        try:
            embedding_req = EmbeddingRequest.from_bytes(buf=buf)
        except msgspec.ValidationError as err:
            logger.info(f"Failed to parse request: {err}")
            resp.status = falcon.HTTP_400
            resp.data = ErrorResponse.from_validation_err(err, str(buf)).to_json()
            return

        emb = await self.client.request(embedding_req)
        if isinstance(emb, Exception):
            resp.status = falcon.HTTP_500
            resp.data = ErrorResponse.from_validation_err(
                emb, "internal error"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…