Build a minimal ``httpx.Response`` for non-inference model-layer requests.
(
url: str, supported_endpoints: list[str] | None = None
)
| 139 | |
| 140 | |
| 141 | def build_non_inference_response( |
| 142 | url: str, supported_endpoints: list[str] | None = None |
| 143 | ) -> httpx.Response: |
| 144 | """Build a minimal ``httpx.Response`` for non-inference model-layer requests.""" |
| 145 | path = url.lower().split("?", 1)[0] # strip query params before matching |
| 146 | if path.endswith("/models"): |
| 147 | return httpx.Response( |
| 148 | 200, |
| 149 | headers={"content-type": "application/json"}, |
| 150 | content=json.dumps(model_catalog(supported_endpoints)).encode(), |
| 151 | ) |
| 152 | if "/models/session" in path: |
| 153 | return httpx.Response(200, headers={"content-type": "application/json"}, content=b"{}") |
| 154 | if "/policy" in path: |
| 155 | return httpx.Response( |
| 156 | 200, |
| 157 | headers={"content-type": "application/json"}, |
| 158 | content=json.dumps({"state": "enabled"}).encode(), |
| 159 | ) |
| 160 | return httpx.Response(200, headers={"content-type": "application/json"}, content=b"{}") |
| 161 | |
| 162 | |
| 163 | def build_inference_response(request: httpx.Request, text: str = SYNTHETIC_TEXT) -> httpx.Response: |
searching dependent graphs…