Skip to content

Commit

Permalink
Add lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davorrunje committed Jan 25, 2025
1 parent d1a5165 commit e50636a
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion autogen/agentchat/contrib/agent_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def record_one_conversation(self, conversation_history: list[dict], is_satisfied
"0",
"1",
], "The input is invalid. Please input 1 or 0. 1 represents satisfied. 0 represents not satisfied."
is_satisfied = True if reply == "1" else False
is_satisfied = reply == "1"
self._trial_conversations_history.append(
{f"Conversation {len(self._trial_conversations_history)}": conversation_history}
)
Expand Down
4 changes: 2 additions & 2 deletions autogen/agentchat/contrib/captainagent/agent_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def build(
.choices[0]
.message.content
)
coding = True if resp == "YES" else False
coding = resp == "YES"

self.cached_configs.update(
{
Expand Down Expand Up @@ -640,7 +640,7 @@ def build_from_library(
.choices[0]
.message.content
)
coding = True if resp == "YES" else False
coding = resp == "YES"

self.cached_configs.update(
{
Expand Down
2 changes: 1 addition & 1 deletion autogen/agentchat/contrib/retrieve_user_proxy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def retrieve_docs(self, problem: str, n_results: int = 20, search_string: str =
self._custom_text_types = self._retrieve_config.get("custom_text_types", TEXT_FORMATS)
self._recursive = self._retrieve_config.get("recursive", True)
self._context_max_tokens = self._retrieve_config.get("context_max_tokens", self._max_tokens * 0.8)
self._collection = True if self._docs_path is None else False # whether the collection is created
self._collection = self._docs_path is None # whether the collection is created
self._ipython = get_ipython()
self._doc_idx = -1 # the index of the current used doc
self._results = [] # the results of the current query
Expand Down
2 changes: 1 addition & 1 deletion autogen/oai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _format_content(content: str) -> str:
@staticmethod
def _is_agent_name_error_message(message: str) -> bool:
pattern = re.compile(r"Invalid 'messages\[\d+\]\.name': string does not match pattern.")
return True if pattern.match(message) else False
return pattern.match(message)

@staticmethod
def _move_system_message_to_beginning(messages: list[dict[str, Any]]) -> None:
Expand Down
2 changes: 1 addition & 1 deletion autogen/oai/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def create(self, params: dict) -> ChatCompletion:
total_tokens = 0

# Stream if in parameters
streaming = True if params.get("stream") else False
streaming = params.get("stream")
cohere_finish = "stop"
tool_calls = None
ans = None
Expand Down
2 changes: 1 addition & 1 deletion notebook/agentchat_teachability.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"user = UserProxyAgent(\n",
" name=\"user\",\n",
" human_input_mode=\"NEVER\",\n",
" is_termination_msg=lambda x: True if \"TERMINATE\" in x.get(\"content\") else False,\n",
" is_termination_msg=lambda x: \"TERMINATE\" in x.get(\"content\"),\n",
" max_consecutive_auto_reply=0,\n",
" code_execution_config={\n",
" \"use_docker\": False\n",
Expand Down
8 changes: 4 additions & 4 deletions notebook/agentchat_teaching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@
"assistant = autogen.AssistantAgent(\n",
" name=\"assistant\",\n",
" llm_config=llm_config,\n",
" is_termination_msg=lambda x: True if \"TERMINATE\" in x.get(\"content\") else False,\n",
" is_termination_msg=lambda x: \"TERMINATE\" in x.get(\"content\"),\n",
")\n",
"# create a UserProxyAgent instance named \"user_proxy\"\n",
"user_proxy = autogen.UserProxyAgent(\n",
" name=\"user_proxy\",\n",
" human_input_mode=\"NEVER\",\n",
" is_termination_msg=lambda x: True if \"TERMINATE\" in x.get(\"content\") else False,\n",
" is_termination_msg=lambda x: \"TERMINATE\" in x.get(\"content\"),\n",
" max_consecutive_auto_reply=10,\n",
" code_execution_config={\n",
" \"work_dir\": \"work_dir\",\n",
Expand Down Expand Up @@ -809,13 +809,13 @@
"assistant = autogen.AssistantAgent(\n",
" name=\"assistant\",\n",
" llm_config=llm_config,\n",
" is_termination_msg=lambda x: True if \"TERMINATE\" in x.get(\"content\") else False,\n",
" is_termination_msg=lambda x: \"TERMINATE\" in x.get(\"content\"),\n",
")\n",
"# create a UserProxyAgent instance named \"user_proxy\"\n",
"user_proxy = autogen.UserProxyAgent(\n",
" name=\"user_proxy\",\n",
" human_input_mode=\"NEVER\",\n",
" is_termination_msg=lambda x: True if \"TERMINATE\" in x.get(\"content\") else False,\n",
" is_termination_msg=lambda x: \"TERMINATE\" in x.get(\"content\"),\n",
" max_consecutive_auto_reply=10,\n",
" code_execution_config={\n",
" \"work_dir\": \"work_dir\",\n",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ select = [
# "B", # flake8-bugbear https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"Q", # flake8-quotes https://docs.astral.sh/ruff/rules/#flake8-quotes-q
# "T20", # flake8-print https://docs.astral.sh/ruff/rules/#flake8-print-t20
"SIM1", # flake8-simplify https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"SIM2", # flake8-simplify https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
# "PT", # flake8-pytest-style https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
# "PTH", # flake8-use-pathlib https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
# "TCH", # flake8-type-checking https://docs.astral.sh/ruff/rules/#flake8-type-checking-tch
Expand Down
2 changes: 1 addition & 1 deletion test/agentchat/test_function_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def test_update_function(credentials_gpt_4o_mini: Credentials):
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="NEVER",
is_termination_msg=lambda x: True if "TERMINATE" in x.get("content") else False,
is_termination_msg=lambda x: "TERMINATE" in x.get("content"),
)
assistant = autogen.AssistantAgent(name="test", llm_config=llm_config)

Expand Down
2 changes: 1 addition & 1 deletion test/agentchat/test_groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _test_selection_method(method: str):
messages=[],
max_round=6,
speaker_selection_method=method,
allow_repeat_speaker=False if method == "manual" else True,
allow_repeat_speaker=method != "manual",
)
group_chat_manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=False)

Expand Down
6 changes: 3 additions & 3 deletions test/agentchat/test_tool_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_update_tool(credentials_gpt_4o: Credentials):
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="NEVER",
is_termination_msg=lambda x: True if "TERMINATE" in x.get("content") else False,
is_termination_msg=lambda x: "TERMINATE" in x.get("content"),
)
assistant = autogen.AssistantAgent(name="test", llm_config=llm_config)

Expand Down Expand Up @@ -216,7 +216,7 @@ def receive(
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="NEVER",
is_termination_msg=lambda x: True if "TERMINATE" in x.get("content") else False,
is_termination_msg=lambda x: "TERMINATE" in x.get("content"),
)
user_proxy.register_function({"echo": lambda str: str})

Expand Down Expand Up @@ -313,7 +313,7 @@ async def a_receive(
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="NEVER",
is_termination_msg=lambda x: True if "TERMINATE" in x.get("content") else False,
is_termination_msg=lambda x: "TERMINATE" in x.get("content"),
)

def echo(str):
Expand Down

0 comments on commit e50636a

Please sign in to comment.