feat: batch block creation [PRO-1422] (#5050)
feat: batch block creation Co-authored-by: Shubham Naik <shub@memgpt.ai>
This commit is contained in:
committed by
Caren Thomas
parent
a3545110cf
commit
74008fb0ed
@@ -1127,6 +1127,9 @@ paths:
|
||||
/v1/_internal_templates/blocks:
|
||||
post:
|
||||
x-fern-ignore: true
|
||||
/v1/_internal_templates/blocks/batch:
|
||||
post:
|
||||
x-fern-ignore: true
|
||||
/v1/projects:
|
||||
get:
|
||||
x-fern-sdk-group-name:
|
||||
|
||||
@@ -8026,6 +8026,55 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/_internal_templates/blocks/batch": {
|
||||
"post": {
|
||||
"tags": ["_internal_templates"],
|
||||
"summary": "Create Blocks Batch",
|
||||
"description": "Create multiple blocks with template-related fields.",
|
||||
"operationId": "create_internal_template_blocks_batch",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/InternalTemplateBlockCreate"
|
||||
},
|
||||
"title": "Blocks"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Block"
|
||||
},
|
||||
"title": "Response Create Internal Template Blocks Batch"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/_internal_templates/deployment/{deployment_id}": {
|
||||
"get": {
|
||||
"tags": ["_internal_templates"],
|
||||
|
||||
@@ -61,6 +61,27 @@ async def create_block(
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.post("/blocks/batch", response_model=List[Block], operation_id="create_internal_template_blocks_batch")
|
||||
async def create_blocks_batch(
|
||||
blocks: List[InternalTemplateBlockCreate] = Body(...),
|
||||
server: "SyncServer" = Depends(get_letta_server),
|
||||
headers: HeaderParams = Depends(get_headers),
|
||||
):
|
||||
"""
|
||||
Create multiple blocks with template-related fields.
|
||||
"""
|
||||
try:
|
||||
actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id)
|
||||
created_blocks = []
|
||||
for block in blocks:
|
||||
block_obj = Block(**block.model_dump())
|
||||
created_block = await server.block_manager.create_or_update_block_async(block_obj, actor=actor)
|
||||
created_blocks.append(created_block)
|
||||
return created_blocks
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
class DeploymentEntity(BaseModel):
|
||||
"""A deployment entity."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user