Files
Imago/sdk/imago_client/resources/ai.py
T
bruno 2f2a5e9b4a
CI / Lint & Format (push) Failing after 28s
CI / Tests (push) Has been skipped
CI / Security Scan (push) Failing after 8s
CI / Docker Build (push) Has been skipped
Add admin panel, WebSocket support, and API versioning
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.
2026-06-22 11:25:22 -04:00

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})