INNER CODE UNIT · Python

_proxy

pathwaycom/llm-app · serviette/frontend/main.py:81

    async def _proxy(name: str, request: Request) -> JSONResponse:
        try:
            body = await request.json()
        except Exception:  # noqa: BLE001 - any malformed body proxies as empty
            body = {}
        assert client is not None  # created in lifespan before serving
        try:
            upstream = await client.post(_PROXY_ROUTES[name], json=body)
        except httpx.HTTPError as exc:
            return JSONResponse(
                {"detail": f"Could not reach the API at {fe.api_url}: {exc}"},
                status_code=502,
            )
        try:
            payload = upstream.json()
        except ValueError:
            payload = {"detail": upstream.text}
        return JSONResponse(payload, status_code=upstream.status_code)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…