🐫 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
chore: add qwq model, update based on code review (#1237)
Wendong-Fana629891f06a0
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 132af1255..53cc8e474 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -130,8 +130,10 @@ Args:`GPT_4O_MINI`. (default: :obj:`OpenAIModel` with `GPT_4O_MINI`)```-### Naming Principle 🛡️-#### Avoid Abbreviations in Naming+### Principles 🛡️++#### Naming Principle: Avoid Abbreviations in Naming+- Abbreviations can lead to ambiguity, especially since variable names and code in CAMEL are directly used by agents.- Use clear, descriptive names that convey meaning without requiring additional explanation. This improves both human readability and the agent's ability to interpret the code.@@ -142,6 +144,24 @@ Examples:By adhering to this principle, we ensure that CAMEL remains accessible and unambiguous for both developers and AI agents.+#### Logging Principle: Use `logger` Instead of `print`++Avoid using `print` for output. Use Python's `logging` module (`logger`) to ensure consistent, configurable, and professional logging.++Examples:++- Bad:+ ```python+ print("Process started")+ print(f"User input: {user_input}")+ ```+- Good:+ ```python+ Args:+ logger.info("Process started")+ logger.debug(f"User input: {user_input}")+ ```+### Board Item Create Workflow 🛠️At CAMEL, we manage our project through a structured workflow that ensures efficiency and clarity in our development process. Our workflow includes stages for issue creation and pull requests (PRs), sprint planning, and reviews.diff --git a/camel/toolkits/human_toolkit.py b/camel/toolkits/human_toolkit.pyindex b8b92785a..a9774825d 100644--- a/camel/toolkits/human_toolkit.py+++ b/camel/toolkits/human_toolkit.py@@ -12,11 +12,14 @@# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import loggingfrom typing import Listfrom camel.toolkits.base import BaseToolkitfrom camel.toolkits.function_tool import FunctionTool+logger = logging.getLogger(__name__)+class HumanToolkit(BaseToolkit):r"""A class representing a toolkit for human interaction."""@@ -24,7 +27,7 @@ class HumanToolkit(BaseToolkit):def __init__(self):pass- def ask_human(self, question: str) -> str:+ def ask_human_via_console(self, question: str) -> str:r"""Ask a question to the human via the console.Args:@@ -33,9 +36,10 @@ class HumanToolkit(BaseToolkit):Returns:str: The answer from the human."""- print(f"\n{question}")- print("Your reply: ", end="")- return input()+ logger.info(f"Question: {question}")+ reply = input("Your reply: ")+ logger.info(f"User reply: {reply}")+ return replydef get_tools(self) -> List[FunctionTool]:r"""Returns a list of FunctionTool objects representing the@@ -45,4 +49,4 @@ class HumanToolkit(BaseToolkit):List[FunctionTool]: A list of FunctionTool objectsrepresenting the functions in the toolkit."""- return [FunctionTool(self.ask_human)]+ return [FunctionTool(self.ask_human_via_console)]diff --git a/docs/index.rst b/docs/index.rstindex ca6b993f3..d17dc1b84 100644--- a/docs/index.rst+++ b/docs/index.rst@@ -5,7 +5,7 @@Welcome to CAMEL's documentation!=================================-| **Finding the Scaling Law of Agents. The first and the best multi-agent framework**+| **Finding the Scaling Law of Agents: The First and the Best Multi-Agent Framework.**| **CAMEL** emerges as the earliest `LLM-based multi-agent framework <https://arxiv.org/pdf/2303.17760.pdf>`_, and is now a generic framework to build and use LLM-based agents for real-world task solving. We believe that studying these agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks. To facilitate research in this field, we implement and support various types of agents, tasks, prompts, models, and simulated environments.diff --git a/examples/models/qwq_model_example.py b/examples/models/qwq_model_example.pynew file mode 100644index 000000000..b94f42065--- /dev/null+++ b/examples/models/qwq_model_example.py@@ -0,0 +1,85 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========++from camel.agents import ChatAgent+from camel.models import ModelFactory+from camel.types import ModelPlatformType++ollama_model = ModelFactory.create(+ model_platform=ModelPlatformType.OLLAMA,+ model_type="qwq",+ model_config_dict={"temperature": 0.4},+)++assistant_sys_msg = """You are a helpful and harmless assistant. You are Qwen+developed by Alibaba. You should think step-by-step."""++agent = ChatAgent(assistant_sys_msg, model=ollama_model, token_limit=4096)++user_msg = """How many r in strawberry."""++assistant_response = agent.step(user_msg)+print(assistant_response.msg.content)++"""+===============================================================================+Let's see. The word is "strawberry." I need to find out how many 'r's are in+it. Okay, first, I'll spell it out slowly: s-t-r-a-w-b-e-r-r-y. Okay, now,+I'll count the 'r's. Let's see: there's an 'r' after the 't', then another 'r'+between the two 'r's towards the end, and one more at the end. Wait, no. Let's+look again.++Spell it again: s-t-r-a-w-b-e-r-r-y.++Now, let's identify the positions of 'r':++1. The third letter is 'r'.++2. The eighth letter is 'r'.++3. The ninth letter is 'r'.++So, there are three 'r's in "strawberry."++But wait, let me double-check. Sometimes I might miscount. Let's list them out:++1. The first 'r' is the third letter.++2. The second 'r' is the eighth letter.++3. The third 'r' is the ninth letter.++Yes, that seems correct. So, the answer is three.++Alternatively, I can think about the pronunciation or the way the word is+structured, but I think just spelling it out and counting is the most+straightforward way.++Another way could be to break it down into syllables: straw-ber-ry. In "straw,+" there's one 'r'. In "ber," there's another 'r'. And in "ry," there's another+'r'. So, again, three 'r's.++Wait, but in "ry," is there really an 'r'? Yes, "ry" has an 'r' and a 'y'. So,+that accounts for the third 'r'.++So, whether I spell it out letter by letter or break it into syllables, I end+up with three 'r's.++I think that's pretty conclusive.++**Final Answer**++\[ \boxed{3} \]+===============================================================================+"""