Skip to content

Commit

Permalink
Updated context variable access methods, update_agent_before_reply pa…
Browse files Browse the repository at this point in the history
…rameter name changed

Signed-off-by: Mark Sze <mark@sze.family>
  • Loading branch information
marklysze committed Nov 30, 2024
1 parent 8fddf90 commit d212e2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions autogen/agentchat/contrib/swarm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def __init__(
human_input_mode: Literal["ALWAYS", "NEVER", "TERMINATE"] = "NEVER",
description: Optional[str] = None,
code_execution_config=False,
update_state_functions: Optional[Union[List[Callable], Callable]] = None,
update_agent_before_reply: Optional[Union[List[Callable], Callable]] = None,
**kwargs,
) -> None:
super().__init__(
Expand Down Expand Up @@ -315,9 +315,9 @@ def __init__(
# use in the tool execution agent to transfer to the next agent
self._next_agent = None

self.register_update_state_functions(update_state_functions)
self.register_update_agent_before_reply(update_agent_before_reply)

def register_update_state_functions(self, functions: Optional[Union[List[Callable], Callable]]):
def register_update_agent_before_reply(self, functions: Optional[Union[List[Callable], Callable]]):
"""
Register functions that will be called when the agent is selected and before it speaks.
You can add your own validation or precondition functions here.
Expand Down
8 changes: 4 additions & 4 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def system_message(self) -> str:
"""Return the system message."""
return self._oai_system_message[0]["content"]

def get_context(self, key: str, default: Any = None) -> Any:
def get_context_value(self, key: str, default: Any = None) -> Any:
"""
Get a context variable by key.
Expand All @@ -543,7 +543,7 @@ def get_context(self, key: str, default: Any = None) -> Any:
"""
return self._context_variables.get(key, default)

def set_context(self, key: str, value: Any) -> None:
def set_context_value(self, key: str, value: Any) -> None:
"""
Set a context variable.
Expand All @@ -553,7 +553,7 @@ def set_context(self, key: str, value: Any) -> None:
"""
self._context_variables[key] = value

def update_context(self, context_variables: Dict[str, Any]) -> None:
def set_context_values(self, context_variables: Dict[str, Any]) -> None:
"""
Update multiple context variables at once.
Expand All @@ -562,7 +562,7 @@ def update_context(self, context_variables: Dict[str, Any]) -> None:
"""
self._context_variables.update(context_variables)

def pop_context(self, key: str, default: Any = None) -> Any:
def pop_context_key(self, key: str, default: Any = None) -> Any:
"""
Remove and return a context variable.
Expand Down

0 comments on commit d212e2b

Please sign in to comment.