🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
Fix mypy errors (#185)
Dmitrii Khizbullinf4de3ffd5d6b
diff --git a/apps/agents/agents.py b/apps/agents/agents.pyindex 23c0be260..408ac7452 100644--- a/apps/agents/agents.py+++ b/apps/agents/agents.py@@ -214,8 +214,8 @@ def role_playing_chat_init(state) -> \session: RolePlaying = state.sessiontry:- init_assistant_msg, _ = session.init_chat()init_assistant_msg: BaseMessage+ init_assistant_msg, _ = session.init_chat()except (openai.error.RateLimitError, tenacity.RetryError,RuntimeError) as ex:print("OpenAI API exception 1 " + str(ex))diff --git a/apps/data_explorer/data_explorer.py b/apps/data_explorer/data_explorer.pyindex dbd3a918f..62875f3b5 100644--- a/apps/data_explorer/data_explorer.py+++ b/apps/data_explorer/data_explorer.py@@ -52,7 +52,8 @@ def parse_arguments():return args-def construct_ui(blocks, datasets: Datasets, default_dataset: str = None):+def construct_ui(blocks, datasets: Datasets,+ default_dataset: Optional[str] = None):""" Build Gradio UI and populate with chat data from JSONs.Args:@@ -226,7 +227,7 @@ def construct_ui(blocks, datasets: Datasets, default_dataset: str = None):Returns:List[Tuple]: Chat history in chatbot UI element format."""- history = []+ history: List[Tuple] = []curr_qa = (None, None)for k in sorted(messages.keys()):msg = messages[k]diff --git a/apps/data_explorer/loader.py b/apps/data_explorer/loader.pyindex 103eface0..7b3a0ee49 100644--- a/apps/data_explorer/loader.py+++ b/apps/data_explorer/loader.py@@ -18,7 +18,7 @@ Everything related to parsing the data JSONs into UI-compatible format.import globimport osimport re-from typing import Any, Dict, List, Optional, Tuple, Union+from typing import Any, Dict, Optional, Tuple, Unionfrom tqdm import tqdm@@ -111,17 +111,17 @@ def load_zip(zip_path: str) -> AllChats:continueparsed_list.append(parsed)- assistant_roles = set()- user_roles = set()+ assistant_roles_set = set()+ user_roles_set = set()for parsed in parsed_list:- assistant_roles.add(parsed['assistant_role'])- user_roles.add(parsed['user_role'])- assistant_roles = list(sorted(assistant_roles))- user_roles = list(sorted(user_roles))- matrix: Dict[Tuple[str, str], List[Dict]] = dict()+ assistant_roles_set.add(parsed['assistant_role'])+ user_roles_set.add(parsed['user_role'])+ assistant_roles = list(sorted(assistant_roles_set))+ user_roles = list(sorted(user_roles_set))+ matrix: Dict[Tuple[str, str], Dict[str, Dict]] = dict()for parsed in parsed_list:key = (parsed['assistant_role'], parsed['user_role'])- original_task = parsed['original_task']+ original_task: str = parsed['original_task']new_item = {k: vfor k, v in parsed.items()diff --git a/camel/societies/role_playing.py b/camel/societies/role_playing.pyindex 76aa7fdd1..652a21210 100644--- a/camel/societies/role_playing.py+++ b/camel/societies/role_playing.py@@ -11,7 +11,7 @@# See the License for the specific language governing permissions and# limitations under the License.# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========-from typing import Dict, List, Optional, Sequence, Tuple+from typing import Dict, List, Optional, Sequence, Tuple, Unionfrom camel.agents import (ChatAgent,@@ -23,6 +23,7 @@ from camel.agents.chat_agent import ChatAgentResponsefrom camel.generators import SystemMessageGeneratorfrom camel.human import Humanfrom camel.messages import BaseMessage+from camel.prompts import TextPromptfrom camel.typing import ModelType, RoleType, TaskType@@ -95,6 +96,7 @@ class RolePlaying:self.model_type = model_typeself.task_type = task_type+ self.specified_task_prompt: Optional[TextPrompt]if with_task_specify:task_specify_meta_dict = dict()if self.task_type in [TaskType.AI_SOCIETY, TaskType.MISALIGNMENT]:@@ -118,6 +120,7 @@ class RolePlaying:else:self.specified_task_prompt = None+ self.planned_task_prompt: Optional[TextPrompt]if with_task_planner:task_planner_agent = TaskPlannerAgent(self.model_type,@@ -173,6 +176,7 @@ class RolePlaying:)self.user_sys_msg = self.user_agent.system_message+ self.critic: Union[CriticAgent, Human, None]if with_critic_in_the_loop:if critic_role_name.lower() == "human":self.critic = Human(**(critic_kwargs or {}))diff --git a/examples/misalignment/role_playing_with_human.py b/examples/misalignment/role_playing_with_human.pyindex c75945ed0..20b22d4f2 100644--- a/examples/misalignment/role_playing_with_human.py+++ b/examples/misalignment/role_playing_with_human.py@@ -29,7 +29,7 @@ def main() -> None:"CAMEL AGI",task_prompt=task_prompt,with_task_specify=True,- with_human_in_the_loop=True,+ with_critic_in_the_loop=True,task_type=TaskType.MISALIGNMENT,task_specify_agent_kwargs=dict(model_config=ChatGPTConfig(temperature=1.4)),diff --git a/examples/summarization/gpt_solution_extraction.py b/examples/summarization/gpt_solution_extraction.pyindex 17d842197..70b390bb1 100644--- a/examples/summarization/gpt_solution_extraction.py+++ b/examples/summarization/gpt_solution_extraction.py@@ -102,10 +102,10 @@ def flatten_conversation(conversation: Dict) -> str:def format_combination(combination: Tuple[int, int, int]):assistant_role, user_role, task = combination- assistant_role = str(assistant_role).zfill(3)- user_role = str(user_role).zfill(3)- task = str(task).zfill(3)- return f"{assistant_role}_{user_role}_{task}"+ assistant_role_str = str(assistant_role).zfill(3)+ user_role_str = str(user_role).zfill(3)+ task_str = str(task).zfill(3)+ return f"{assistant_role_str}_{user_role_str}_{task_str}"def solution_extraction(conversation: Dict, flattened_conversation: str,