diff --git a/autogpt_platform/backend/backend/server/v2/llm/admin_routes.py b/autogpt_platform/backend/backend/server/v2/llm/admin_routes.py index c99f6b2c48..b19f07d9aa 100644 --- a/autogpt_platform/backend/backend/server/v2/llm/admin_routes.py +++ b/autogpt_platform/backend/backend/server/v2/llm/admin_routes.py @@ -1,10 +1,11 @@ -"""Admin write API for LLM registry management. +"""Admin API for LLM registry management. -Provides endpoints for creating, updating, and deleting: -- Models -- Providers +Provides endpoints for: +- Reading creators (GET) +- Creating, updating, and deleting models +- Creating, updating, and deleting providers -All endpoints require admin authentication and refresh the registry cache after mutations. +All endpoints require admin authentication. Mutations refresh the registry cache. """ import logging @@ -67,6 +68,21 @@ def _map_model_response(model: Any) -> dict[str, Any]: } +def _map_creator_response(creator: Any) -> dict[str, Any]: + """Map Prisma creator model to response dict.""" + return { + "id": creator.id, + "name": creator.name, + "display_name": creator.displayName, + "description": creator.description, + "website_url": creator.websiteUrl, + "logo_url": creator.logoUrl, + "metadata": dict(creator.metadata or {}), + "created_at": creator.createdAt.isoformat() if creator.createdAt else None, + "updated_at": creator.updatedAt.isoformat() if creator.updatedAt else None, + } + + @router.post( "/llm/models", status_code=status.HTTP_201_CREATED, @@ -307,3 +323,25 @@ async def delete_provider( except Exception as e: logger.exception(f"Failed to delete provider: {e}") raise HTTPException(status_code=500, detail="Failed to delete provider") + + +@router.get( + "/llm/creators", + dependencies=[Security(autogpt_libs.auth.requires_admin_user)], +) +async def list_creators() -> dict[str, Any]: + """List all LLM model creators. + + Requires admin authentication. + """ + try: + import prisma.models + + creators = await prisma.models.LlmModelCreator.prisma().find_many( + order={"name": "asc"} + ) + logger.info(f"Retrieved {len(creators)} creators") + return {"creators": [_map_creator_response(c) for c in creators]} + except Exception as e: + logger.exception(f"Failed to list creators: {e}") + raise HTTPException(status_code=500, detail="Failed to list creators") diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json index 4aeea59073..3be63d5eb9 100644 --- a/autogpt_platform/frontend/src/app/api/openapi.json +++ b/autogpt_platform/frontend/src/app/api/openapi.json @@ -4603,6 +4603,32 @@ } } }, + "/api/llm/creators": { + "get": { + "tags": ["v2", "llm", "admin"], + "summary": "List Creators", + "description": "List all LLM model creators.\n\nRequires admin authentication.", + "operationId": "getV2ListCreators", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "additionalProperties": true, + "type": "object", + "title": "Response Getv2Listcreators" + } + } + } + }, + "401": { + "$ref": "#/components/responses/HTTP401NotAuthenticatedError" + } + }, + "security": [{ "HTTPBearerJWT": [] }] + } + }, "/api/llm/models": { "get": { "tags": ["v2", "llm", "llm"],