feat: add cloud template fields to blocks/groups/agents [LET-3979]
* commit * fix tests * add routes * remove old fields * remove entity from group * generate, migrate * update * keep from_template, etc. * keep block fields * final * generate * pass tests * generate * keep defaults --------- Co-authored-by: jin <jin@letta.com>
This commit is contained in:
@@ -4553,7 +4553,8 @@ def test_create_block(server: SyncServer, default_user):
|
||||
label="human",
|
||||
is_template=True,
|
||||
value="Sample content",
|
||||
template_name="sample_template",
|
||||
template_name="sample_template_name",
|
||||
template_id="sample_template",
|
||||
description="A test block",
|
||||
limit=1000,
|
||||
metadata={"example": "data"},
|
||||
@@ -4566,6 +4567,7 @@ def test_create_block(server: SyncServer, default_user):
|
||||
assert block.is_template == block_create.is_template
|
||||
assert block.value == block_create.value
|
||||
assert block.template_name == block_create.template_name
|
||||
assert block.template_id == block_create.template_id
|
||||
assert block.description == block_create.description
|
||||
assert block.limit == block_create.limit
|
||||
assert block.metadata == block_create.metadata
|
||||
@@ -10940,6 +10942,78 @@ FAILED tests/test_managers.py::test_high_concurrency_stress_test - AssertionErro
|
||||
# await server.block_manager.delete_block_async(block.id, actor=default_user)
|
||||
|
||||
|
||||
def test_create_internal_template_objects(server: SyncServer, default_user):
|
||||
"""Test creating agents, groups, and blocks with template-related fields."""
|
||||
from letta.schemas.agent import InternalTemplateAgentCreate
|
||||
from letta.schemas.block import Block, InternalTemplateBlockCreate
|
||||
from letta.schemas.group import InternalTemplateGroupCreate, RoundRobinManager
|
||||
|
||||
base_template_id = "base_123"
|
||||
template_id = "template_456"
|
||||
deployment_id = "deploy_789"
|
||||
entity_id = "entity_012"
|
||||
|
||||
# Create agent with template fields (use sarah_agent as base, then create new one)
|
||||
agent = server.agent_manager.create_agent(
|
||||
InternalTemplateAgentCreate(
|
||||
name="template-agent",
|
||||
base_template_id=base_template_id,
|
||||
template_id=template_id,
|
||||
deployment_id=deployment_id,
|
||||
entity_id=entity_id,
|
||||
llm_config=LLMConfig.default_config("gpt-4o-mini"),
|
||||
embedding_config=EmbeddingConfig.default_config(provider="openai"),
|
||||
include_base_tools=False,
|
||||
),
|
||||
actor=default_user,
|
||||
)
|
||||
# Verify agent template fields
|
||||
assert agent.base_template_id == base_template_id
|
||||
assert agent.template_id == template_id
|
||||
assert agent.deployment_id == deployment_id
|
||||
assert agent.entity_id == entity_id
|
||||
|
||||
# Create block with template fields
|
||||
block_create = InternalTemplateBlockCreate(
|
||||
label="template_block",
|
||||
value="Test block",
|
||||
base_template_id=base_template_id,
|
||||
template_id=template_id,
|
||||
deployment_id=deployment_id,
|
||||
entity_id=entity_id,
|
||||
)
|
||||
block = server.block_manager.create_or_update_block(Block(**block_create.model_dump()), actor=default_user)
|
||||
# Verify block template fields
|
||||
assert block.base_template_id == base_template_id
|
||||
assert block.template_id == template_id
|
||||
assert block.deployment_id == deployment_id
|
||||
assert block.entity_id == entity_id
|
||||
|
||||
# Create group with template fields (no entity_id for groups)
|
||||
group = server.group_manager.create_group(
|
||||
InternalTemplateGroupCreate(
|
||||
agent_ids=[agent.id],
|
||||
description="Template group",
|
||||
base_template_id=base_template_id,
|
||||
template_id=template_id,
|
||||
deployment_id=deployment_id,
|
||||
manager_config=RoundRobinManager(),
|
||||
),
|
||||
actor=default_user,
|
||||
)
|
||||
# Verify group template fields and basic functionality
|
||||
assert group.description == "Template group"
|
||||
assert agent.id in group.agent_ids
|
||||
assert group.base_template_id == base_template_id
|
||||
assert group.template_id == template_id
|
||||
assert group.deployment_id == deployment_id
|
||||
|
||||
# Clean up
|
||||
server.group_manager.delete_group(group.id, actor=default_user)
|
||||
server.block_manager.delete_block(block.id, actor=default_user)
|
||||
server.agent_manager.delete_agent(agent.id, actor=default_user)
|
||||
|
||||
|
||||
# TODO: I use this as a way to easily wipe my local db lol sorry
|
||||
# TODO: Leave this in here I constantly wipe my db for testing unless you care about optics
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user