Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat(asyncify): delete source sleeptime (#2459)

cthomas207e6e5bbe47
diff --git a/letta/server/rest_api/routers/v1/sources.py b/letta/server/rest_api/routers/v1/sources.py
index 9dc42808a..889d272c1 100644
--- a/letta/server/rest_api/routers/v1/sources.py
+++ b/letta/server/rest_api/routers/v1/sources.py
@@ -137,14 +137,13 @@ async def delete_source(
Delete a data source.
"""
actor = await server.user_manager.get_actor_or_default_async(actor_id=actor_id)
- source = await server.source_manager.get_source_by_id(source_id=source_id)
+ source = await server.source_manager.get_source_by_id(source_id=source_id, actor=actor)
agents = await server.source_manager.list_attached_agents(source_id=source_id, actor=actor)
for agent in agents:
if agent.enable_sleeptime:
try:
- # TODO: make async
- block = server.agent_manager.get_block_with_label(agent_id=agent.id, block_label=source.name, actor=actor)
- server.block_manager.delete_block(block.id, actor)
+ block = await server.agent_manager.get_block_with_label_async(agent_id=agent.id, block_label=source.name, actor=actor)
+ await server.block_manager.delete_block_async(block.id, actor)
except:
pass
await server.delete_source(source_id=source_id, actor=actor)