Introduce an admin portal (React + Nginx), WebSocket routing, and API versioning middleware with `/api/v1/` prefix deprecation. Add master API key authentication, new Prometheus metrics for AI token consumption and active WebSockets, and extend S3 config with a public endpoint URL. Update test paths and fixtures to align with the new routing structure.
26 lines
986 B
Python
26 lines
986 B
Python
"""
|
|
AI endpoints interaction.
|
|
"""
|
|
from typing import Any, Dict
|
|
from httpx import AsyncClient
|
|
|
|
from ..utils import with_retry
|
|
|
|
class AIResource:
|
|
"""Resource defining AI generative operations."""
|
|
def __init__(self, client: AsyncClient):
|
|
self._client = client
|
|
|
|
async def _handle_request(self, method: str, path: str, **kwargs) -> Any:
|
|
async def _req():
|
|
resp = await self._client.request(method, path, **kwargs)
|
|
resp.raise_for_status()
|
|
return resp.json()
|
|
return await with_retry(_req)
|
|
|
|
async def summarize_url(self, url: str, language: str = "français") -> Dict[str, Any]:
|
|
return await self._handle_request("POST", "/api/v1/ai/summarize", json={"url": url, "language": language})
|
|
|
|
async def draft_task(self, description: str, context: str = "") -> Dict[str, Any]:
|
|
return await self._handle_request("POST", "/api/v1/ai/draft-task", json={"description": description, "context": context})
|