refactor: [conversable_agent] remove raise from property access (#2006)

* refactor: [conversable_agent] remove raise from property access

raising exception seems drastic, can we return None and let the called fail in case it receives a None?

* Update conversable_agent.py

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
This commit is contained in:
Eduardo Salinas
2024-03-15 00:40:49 -04:00
committed by GitHub
parent 08ba070936
commit 146d49b2e3

View File

@@ -270,13 +270,10 @@ class ConversableAgent(LLMAgent):
self._description = description
@property
def code_executor(self) -> CodeExecutor:
"""The code executor used by this agent. Raise if code execution is disabled."""
def code_executor(self) -> Optional[CodeExecutor]:
"""The code executor used by this agent. Returns None if code execution is disabled."""
if not hasattr(self, "_code_executor"):
raise ValueError(
"No code executor as code execution is disabled. "
"To enable code execution, set code_execution_config."
)
return None
return self._code_executor
def register_reply(