| 79 | |
| 80 | |
| 81 | async def fetch_non_streaming( |
| 82 | session: aiohttp.ClientSession, |
| 83 | url: str, |
| 84 | params: dict[str, Any], |
| 85 | payload: dict[str, Any] | None, |
| 86 | ) -> Any: |
| 87 | request_kwargs: dict[str, Any] = {"params": params} |
| 88 | if payload is not None: |
| 89 | request_kwargs["json"] = payload |
| 90 | |
| 91 | http_method = session.get if payload is None else session.post |
| 92 | async with http_method(url, **request_kwargs) as response: |
| 93 | response.raise_for_status() |
| 94 | return await response.json() |
| 95 | |
| 96 | |
| 97 | def extract_messages(payload: Any) -> list[dict[str, Any]]: |