Shub/let 1646 add agentfile to cloud (#1540)
Co-authored-by: Shubham Naik <shub@memgpt.ai>
This commit is contained in:
@@ -130,6 +130,10 @@ async def import_agent_serialized(
|
||||
description="If set to True, existing tools can get their source code overwritten by the uploaded tool definitions. Note that Letta core tools can never be updated externally.",
|
||||
),
|
||||
project_id: Optional[str] = Query(None, description="The project ID to associate the uploaded agent with."),
|
||||
strip_messages: bool = Query(
|
||||
False,
|
||||
description="If set to True, strips all messages from the agent before importing.",
|
||||
),
|
||||
):
|
||||
"""
|
||||
Import a serialized agent file and recreate the agent in the system.
|
||||
@@ -149,6 +153,7 @@ async def import_agent_serialized(
|
||||
append_copy_suffix=append_copy_suffix,
|
||||
override_existing_tools=override_existing_tools,
|
||||
project_id=project_id,
|
||||
strip_messages=strip_messages,
|
||||
)
|
||||
return new_agent
|
||||
|
||||
|
||||
@@ -525,6 +525,7 @@ class AgentManager:
|
||||
append_copy_suffix: bool = True,
|
||||
override_existing_tools: bool = True,
|
||||
project_id: Optional[str] = None,
|
||||
strip_messages: Optional[bool] = False,
|
||||
) -> PydanticAgentState:
|
||||
serialized_agent = serialized_agent.model_dump()
|
||||
tool_data_list = serialized_agent.pop("tools", [])
|
||||
@@ -536,6 +537,10 @@ class AgentManager:
|
||||
agent.name += "_copy"
|
||||
if project_id:
|
||||
agent.project_id = project_id
|
||||
|
||||
if strip_messages:
|
||||
# we want to strip all but the first (system) message
|
||||
agent.message_ids = [agent.message_ids[0]]
|
||||
agent = agent.create(session, actor=actor)
|
||||
pydantic_agent = agent.to_pydantic()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user