INNER CODE UNIT · Python
Ping
tensorchord/modelz-llm · src/modelz_llm/falcon_service.py:24
class Ping:
async def on_get(self, req: Request, resp: Response):
resp.content_type = falcon.MEDIA_TEXT
resp.text = "Modelz LLM service"
class ChatCompletions:
def __init__(self, client: Client) -> None:
self.client = client
async def on_post(self, req: Request, resp: Response):
buf = await req.stream.readall()
try:
chat_req = ChatCompletionRequest.from_bytes(buf=buf)
except msgspec.ValidationError as err:
logger.info(f"Failed to parse request: {err}")
# return 400 otherwise the client will retry
resp.status = falcon.HTTP_400