Skip to content

Commit

Permalink
Merge branch 'master' into Claude_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendong-Fan committed Jan 4, 2025
2 parents c367ed7 + 6cb00f5 commit e8475fe
Show file tree
Hide file tree
Showing 38 changed files with 66 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
placeholder: E.g., 0.2.15
placeholder: E.g., 0.2.16
validations:
required: true

Expand Down
10 changes: 7 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.7'
rev: 'v0.7.4'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
exclude: ^docs/cookbooks/ # Ignore files under docs/cookbooks
- id: ruff-format

exclude: ^docs/cookbooks/ # Ignore files under docs/cookbooks

- repo: local
hooks:
- id: mypy
Expand All @@ -15,11 +17,13 @@ repos:
types: [python]
pass_filenames: false
require_serial: true
exclude: ^docs/cookbooks/ # Ignore files under docs/cookbooks

- repo: local
hooks:
- id: check-license
name: Check License
entry: python licenses/update_license.py . licenses/license_template.txt
language: system
types: [python]
types: [python]
exclude: ^docs/cookbooks/ # Ignore files under docs/cookbooks
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
git clone -b v0.2.15 https://github.com/camel-ai/camel.git
git clone -b v0.2.16 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
Expand Down
2 changes: 1 addition & 1 deletion camel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from camel.logger import disable_logging, enable_logging, set_log_level

__version__ = '0.2.15'
__version__ = '0.2.16'

__all__ = [
'__version__',
Expand Down
14 changes: 11 additions & 3 deletions camel/datagen/self_instruct/filter/filter_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ class RewardModelFilter(FilterFunction):
to pass the filter.
"""

def __init__(self, reward_model: BaseRewardModel, threshold: float = 0.5):
def __init__(
self,
reward_model: BaseRewardModel,
threshold: float = 0.5,
):
self.prompt = ""
self.reward_model = reward_model
self.threshold = threshold

Expand All @@ -190,8 +195,11 @@ def apply(self, instruction: str) -> bool:
required score is not found in `scores`.
"""

messages = [{"role": "user", "content": instruction}]
scores = self.reward_model.evaluate(messages)
data = [
{"role": "user", "content": self.prompt},
{"role": "assistant", "content": instruction},
]
scores = self.reward_model.evaluate(data)
score_types = self.reward_model.get_scores_types()
if not score_types:
raise ValueError("No score types available from the reward model.")
Expand Down
9 changes: 7 additions & 2 deletions camel/datagen/self_instruct/filter/instruction_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
from typing import Any, Dict, List

from .filter_function import FilterFunction
from .filter_function import FilterFunction, RewardModelFilter
from .filter_registry import FILTER_REGISTRY


Expand Down Expand Up @@ -53,10 +53,13 @@ def add_filter(self, filter_function: FilterFunction):
"""
self.filters.append(filter_function)

def filter(self, instruction: str, return_details: bool = False):
def filter(
self, prompt: str, instruction: str, return_details: bool = False
):
r"""Check if the given instruction passes all filter functions.
Args:
prompt (str): The prompt of generating the instruction.
instruction (str): The instruction to evaluate.
return_details (bool): If True, returns a tuple (bool, List[str])
where the list contains the names of filters that failed.
Expand All @@ -68,6 +71,8 @@ def filter(self, instruction: str, return_details: bool = False):
"""
failed_filters = []
for f in self.filters:
if isinstance(f, RewardModelFilter):
f.prompt = prompt
if not f.apply(instruction):
failed_filters.append(type(f).__name__)

Expand Down
10 changes: 5 additions & 5 deletions camel/datagen/self_instruct/self_instruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ def sample_machine_tasks(self, count: int) -> List[dict]:

return random.sample(self.machine_tasks, count)

def generate_machine_instruction(self) -> str:
def generate_machine_instruction(self) -> List:
r"""Generate a machine instruction using the agent.
Combines human and machine tasks based on the configured ratio to
create a prompt for instruction generation.
Returns:
str: A machine-generated instruction.
List: The prompt and a machine-generated instruction.
"""

sampled_human_tasks = self.sample_human_tasks(
Expand Down Expand Up @@ -176,7 +176,7 @@ def generate_machine_instruction(self) -> str:
for line in response.msgs[0].content.split("\n")
if line.strip()
]
return generated_tasks[0]
return [prompt, generated_tasks[0]]

def identify_instruction(self, instruction: str) -> bool:
r"""Determine if the given instruction is a classification task.
Expand Down Expand Up @@ -371,8 +371,8 @@ def generate(self):
for f in self.instruction_filter.filters:
if isinstance(f, RougeSimilarityFilter):
f.existing_instructions = existing_instructions
instruction = self.generate_machine_instruction()
if self.instruction_filter.filter(instruction):
prompt, instruction = self.generate_machine_instruction()
if self.instruction_filter.filter(prompt, instruction):
instruction_dict = {
"id": f"machine_task_{len(self.machine_tasks) + 1}",
"instruction": instruction,
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
release = '0.2.14'
release = '0.2.16'

html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_message.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai==0.2.14\""
"!pip install \"camel-ai==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_prompting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai==0.2.14\""
"!pip install \"camel-ai==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_society.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai==0.2.14\""
"!pip install \"camel-ai==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_tracking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"outputs": [],
"source": [
"%pip install camel-ai[all]==0.2.14\n",
"%pip install camel-ai[all]==0.2.16\n",
"%pip install agentops==0.3.10"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_with_memory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.14\""
"!pip install \"camel-ai[all]==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_with_rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.14\""
"!pip install \"camel-ai[all]==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/agents_with_tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.14\""
"!pip install \"camel-ai[all]==0.2.16\""
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"outputs": [],
"source": [
"%%capture\n",
"!pip install camel-ai==0.2.15"
"!pip install camel-ai==0.2.16"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/cot_data_gen_upload_to_huggingface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"outputs": [],
"source": [
"%%capture\n",
"!pip install camel-ai==0.2.15"
"!pip install camel-ai==0.2.16"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/create_your_first_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
{
"cell_type": "code",
"source": [
"!pip install \"camel-ai[all]==0.2.14\""
"!pip install \"camel-ai[all]==0.2.16\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/create_your_first_agents_society.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{
"cell_type": "code",
"source": [
"!pip install \"camel-ai==0.2.14\""
"!pip install \"camel-ai==0.2.16\""
],
"metadata": {
"id": "RiwfwyyLYYxo"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/critic_agents_and_tree_search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
{
"cell_type": "code",
"source": [
"%pip install \"camel-ai==0.2.14\""
"%pip install \"camel-ai==0.2.16\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.14\"\n",
"!pip install \"camel-ai[all]==0.2.16\"\n",
"!pip install starlette\n",
"!pip install nest_asyncio"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"outputId": "72f5cfe5-60ea-48ba-e1e1-a0cdc4eb87ec"
},
"source": [
"!pip install \"camel-ai[all]==0.2.15\"\n",
"!pip install \"camel-ai[all]==0.2.16\"\n",
"!pip install starlette\n",
"!pip install nest_asyncio"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.14\"\n",
"!pip install \"camel-ai[all]==0.2.16\"\n",
"!pip install starlette\n",
"!pip install nest_asyncio"
]
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/embodied_agents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
{
"cell_type": "code",
"source": [
"%pip install \"camel-ai==0.2.14\""
"%pip install \"camel-ai==0.2.16\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
},
"outputs": [],
"source": [
"pip install \"camel-ai[all]==0.2.14\""
"pip install \"camel-ai[all]==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/knowledge_graph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"outputs": [],
"source": [
"pip install \"camel-ai[all]==0.2.14\""
"pip install \"camel-ai[all]==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/model_speed_comparison.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
{
"cell_type": "code",
"source": [
"!pip install \"camel-ai==0.2.14\""
"!pip install \"camel-ai==0.2.16\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/roleplaying_scraper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai[all]==0.2.14\""
"!pip install \"camel-ai[all]==0.2.16\""
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"%%capture\n",
"!pip install unsloth\n",
"# Install CAMEL-AI with no optional dependencies\n",
"!pip install camel-ai==0.2.14\n",
"!pip install camel-ai==0.2.16\n",
"# Get Unsloth latest unsloth nightly\n",
"!pip uninstall unsloth -y && pip install --upgrade --no-cache-dir --no-deps git+https://github.com/unslothai/unsloth.git\n",
"!pip install firecrawl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"%%capture\n",
"!pip install unsloth\n",
"# Install CAMEL-AI with no optional dependencies\n",
"!pip install camel-ai==0.2.14\n",
"!pip install camel-ai==0.2.16\n",
"# Get Unsloth\n",
"!pip install --upgrade --no-deps \"unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@0de54572525788d09a6a9ef1efc7611e65dd7547\"\n",
"!pip install firecrawl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"%%capture\n",
"!pip install unsloth\n",
"# Install CAMEL-AI with no optional dependencies\n",
"!pip install camel-ai==0.2.14\n",
"!pip install camel-ai==0.2.16\n",
"# Get Unsloth\n",
"!pip install --upgrade --no-deps \"unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@0de54572525788d09a6a9ef1efc7611e65dd7547\"\n",
"!pip install firecrawl"
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/task_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"outputs": [],
"source": [
"!pip install \"camel-ai==0.2.14\""
"!pip install \"camel-ai==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/video_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"outputs": [],
"source": [
"%pip install \"camel-ai[all]==0.2.14\""
"%pip install \"camel-ai[all]==0.2.16\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbooks/workforce_judge_committee.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"outputs": [],
"source": [
"%pip install \"camel-ai[all]==0.2.14\""
"%pip install \"camel-ai[all]==0.2.16\""
]
},
{
Expand Down
Loading

0 comments on commit e8475fe

Please sign in to comment.