Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: Add create archive route (#2961)
Matthew Zhou2d828b8d9ab1
diff --git a/letta/server/rest_api/routers/v1/__init__.py b/letta/server/rest_api/routers/v1/__init__.pyindex ba62cef52..81b3f401f 100644--- a/letta/server/rest_api/routers/v1/__init__.py+++ b/letta/server/rest_api/routers/v1/__init__.py@@ -1,4 +1,5 @@from letta.server.rest_api.routers.v1.agents import router as agents_router+from letta.server.rest_api.routers.v1.archives import router as archives_routerfrom letta.server.rest_api.routers.v1.blocks import router as blocks_routerfrom letta.server.rest_api.routers.v1.embeddings import router as embeddings_routerfrom letta.server.rest_api.routers.v1.folders import router as folders_router@@ -20,6 +21,7 @@ from letta.server.rest_api.routers.v1.tools import router as tools_routerfrom letta.server.rest_api.routers.v1.voice import router as voice_routerROUTERS = [+ archives_router,tools_router,sources_router,folders_router,diff --git a/letta/server/rest_api/routers/v1/archives.py b/letta/server/rest_api/routers/v1/archives.pynew file mode 100644index 000000000..13cc36b3e--- /dev/null+++ b/letta/server/rest_api/routers/v1/archives.py@@ -0,0 +1,40 @@+from typing import Optional++from fastapi import APIRouter, Body, Depends, HTTPException+from pydantic import BaseModel++from letta.schemas.archive import Archive as PydanticArchive+from letta.server.rest_api.dependencies import HeaderParams, get_headers, get_letta_server+from letta.server.server import SyncServer++router = APIRouter(prefix="/archives", tags=["archives"])+++class ArchiveCreateRequest(BaseModel):+ """Request model for creating an archive.++ Intentionally excludes vector_db_provider. These are derived internally (vector DB provider from env).+ """++ name: str+ description: Optional[str] = None++[email protected]("/", response_model=PydanticArchive, operation_id="create_archive")+async def create_archive(+ archive: ArchiveCreateRequest = Body(...),+ server: "SyncServer" = Depends(get_letta_server),+ headers: HeaderParams = Depends(get_headers),+):+ """+ Create a new archive.+ """+ try:+ actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id)+ return await server.archive_manager.create_archive_async(+ name=archive.name,+ description=archive.description,+ actor=actor,+ )+ except Exception as e:+ raise HTTPException(status_code=500, detail=str(e))