mirror of
https://github.com/cpacker/MemGPT.git
synced 2025-06-03 04:30:22 +00:00
fix: make tool rules enum mapping one to one (#826)
This commit is contained in:
parent
1bc102e754
commit
1294ff1b7a
1
.composio.lock
Normal file
1
.composio.lock
Normal file
@ -0,0 +1 @@
|
||||
{}
|
@ -235,6 +235,7 @@ class Agent(BaseAgent):
|
||||
# TODO: This is only temporary, can remove after we publish a pip package with this object
|
||||
agent_state_copy = self.agent_state.__deepcopy__()
|
||||
agent_state_copy.tools = []
|
||||
agent_state_copy.tool_rules = []
|
||||
|
||||
sandbox_run_result = ToolExecutionSandbox(function_name, function_args, self.user).run(agent_state=agent_state_copy)
|
||||
function_response, updated_agent_state = sandbox_run_result.func_return, sandbox_run_result.agent_state
|
||||
|
@ -84,11 +84,11 @@ class ToolRulesColumn(TypeDecorator):
|
||||
def deserialize_tool_rule(data: dict) -> Union[ChildToolRule, InitToolRule, TerminalToolRule, ConditionalToolRule]:
|
||||
"""Deserialize a dictionary to the appropriate ToolRule subclass based on the 'type'."""
|
||||
rule_type = ToolRuleType(data.get("type")) # Remove 'type' field if it exists since it is a class var
|
||||
if rule_type == ToolRuleType.run_first:
|
||||
if rule_type == ToolRuleType.run_first or rule_type == "InitToolRule":
|
||||
return InitToolRule(**data)
|
||||
elif rule_type == ToolRuleType.exit_loop:
|
||||
elif rule_type == ToolRuleType.exit_loop or rule_type == "TerminalToolRule":
|
||||
return TerminalToolRule(**data)
|
||||
elif rule_type == ToolRuleType.constrain_child_tools:
|
||||
elif rule_type == ToolRuleType.constrain_child_tools or rule_type == "ToolRule":
|
||||
rule = ChildToolRule(**data)
|
||||
return rule
|
||||
elif rule_type == ToolRuleType.conditional:
|
||||
|
@ -46,9 +46,13 @@ class ToolRuleType(str, Enum):
|
||||
|
||||
# note: some of these should be renamed when we do the data migration
|
||||
|
||||
run_first = "InitToolRule"
|
||||
exit_loop = "TerminalToolRule" # reasoning loop should exit
|
||||
continue_loop = "continue_loop" # reasoning loop should continue
|
||||
run_first = "run_first"
|
||||
exit_loop = "exit_loop" # reasoning loop should exit
|
||||
continue_loop = "continue_loop"
|
||||
conditional = "conditional"
|
||||
constrain_child_tools = "ToolRule"
|
||||
constrain_child_tools = "constrain_child_tools"
|
||||
require_parent_tools = "require_parent_tools"
|
||||
# Deprecated
|
||||
InitToolRule = "InitToolRule"
|
||||
TerminalToolRule = "TerminalToolRule"
|
||||
ToolRule = "ToolRule"
|
||||
|
@ -9,7 +9,7 @@ from letta.schemas.letta_base import LettaBase
|
||||
class BaseToolRule(LettaBase):
|
||||
__id_prefix__ = "tool_rule"
|
||||
tool_name: str = Field(..., description="The name of the tool. Must exist in the database for the user's organization.")
|
||||
type: ToolRuleType
|
||||
type: ToolRuleType = Field(..., description="The type of the message.")
|
||||
|
||||
|
||||
class ChildToolRule(BaseToolRule):
|
||||
|
@ -232,6 +232,7 @@ def agent_state():
|
||||
embedding_config=EmbeddingConfig.default_config(provider="openai"),
|
||||
llm_config=LLMConfig.default_config(model_name="gpt-4"),
|
||||
)
|
||||
agent_state.tool_rules = []
|
||||
yield agent_state
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user