camel-ai 0.2.22__py3-none-any.whl → 0.2.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of camel-ai might be problematic. Click here for more details.
- camel/__init__.py +1 -1
- camel/agents/_types.py +41 -0
- camel/agents/_utils.py +188 -0
- camel/agents/chat_agent.py +570 -965
- camel/agents/knowledge_graph_agent.py +7 -1
- camel/agents/multi_hop_generator_agent.py +1 -1
- camel/configs/base_config.py +10 -13
- camel/configs/deepseek_config.py +4 -30
- camel/configs/gemini_config.py +5 -31
- camel/configs/openai_config.py +14 -32
- camel/configs/qwen_config.py +36 -36
- camel/datagen/self_improving_cot.py +81 -3
- camel/datagen/self_instruct/filter/instruction_filter.py +19 -3
- camel/datagen/self_instruct/self_instruct.py +52 -3
- camel/datasets/__init__.py +28 -0
- camel/datasets/base.py +969 -0
- camel/environments/__init__.py +16 -0
- camel/environments/base.py +503 -0
- camel/extractors/__init__.py +16 -0
- camel/extractors/base.py +263 -0
- camel/memories/agent_memories.py +16 -1
- camel/memories/blocks/chat_history_block.py +10 -2
- camel/memories/blocks/vectordb_block.py +1 -0
- camel/memories/context_creators/score_based.py +20 -3
- camel/memories/records.py +10 -0
- camel/messages/base.py +8 -8
- camel/models/__init__.py +2 -0
- camel/models/_utils.py +57 -0
- camel/models/aiml_model.py +48 -17
- camel/models/anthropic_model.py +41 -3
- camel/models/azure_openai_model.py +39 -3
- camel/models/base_audio_model.py +92 -0
- camel/models/base_model.py +88 -13
- camel/models/cohere_model.py +88 -11
- camel/models/deepseek_model.py +107 -45
- camel/models/fish_audio_model.py +18 -8
- camel/models/gemini_model.py +133 -15
- camel/models/groq_model.py +72 -10
- camel/models/internlm_model.py +14 -3
- camel/models/litellm_model.py +9 -2
- camel/models/mistral_model.py +42 -5
- camel/models/model_manager.py +57 -3
- camel/models/moonshot_model.py +33 -4
- camel/models/nemotron_model.py +32 -3
- camel/models/nvidia_model.py +43 -3
- camel/models/ollama_model.py +139 -17
- camel/models/openai_audio_models.py +87 -2
- camel/models/openai_compatible_model.py +37 -3
- camel/models/openai_model.py +158 -46
- camel/models/qwen_model.py +61 -4
- camel/models/reka_model.py +53 -3
- camel/models/samba_model.py +209 -4
- camel/models/sglang_model.py +153 -14
- camel/models/siliconflow_model.py +16 -3
- camel/models/stub_model.py +46 -4
- camel/models/togetherai_model.py +38 -3
- camel/models/vllm_model.py +37 -3
- camel/models/yi_model.py +36 -3
- camel/models/zhipuai_model.py +38 -3
- camel/retrievers/__init__.py +3 -0
- camel/retrievers/hybrid_retrival.py +237 -0
- camel/toolkits/__init__.py +15 -1
- camel/toolkits/arxiv_toolkit.py +2 -1
- camel/toolkits/ask_news_toolkit.py +4 -2
- camel/toolkits/audio_analysis_toolkit.py +238 -0
- camel/toolkits/base.py +22 -3
- camel/toolkits/code_execution.py +2 -0
- camel/toolkits/dappier_toolkit.py +2 -1
- camel/toolkits/data_commons_toolkit.py +38 -12
- camel/toolkits/excel_toolkit.py +172 -0
- camel/toolkits/function_tool.py +13 -0
- camel/toolkits/github_toolkit.py +5 -1
- camel/toolkits/google_maps_toolkit.py +2 -1
- camel/toolkits/google_scholar_toolkit.py +2 -0
- camel/toolkits/human_toolkit.py +0 -3
- camel/toolkits/image_analysis_toolkit.py +202 -0
- camel/toolkits/linkedin_toolkit.py +3 -2
- camel/toolkits/meshy_toolkit.py +3 -2
- camel/toolkits/mineru_toolkit.py +2 -2
- camel/toolkits/networkx_toolkit.py +240 -0
- camel/toolkits/notion_toolkit.py +2 -0
- camel/toolkits/openbb_toolkit.py +3 -2
- camel/toolkits/page_script.js +376 -0
- camel/toolkits/reddit_toolkit.py +11 -3
- camel/toolkits/retrieval_toolkit.py +6 -1
- camel/toolkits/semantic_scholar_toolkit.py +2 -1
- camel/toolkits/stripe_toolkit.py +8 -2
- camel/toolkits/sympy_toolkit.py +6 -1
- camel/toolkits/video_analysis_toolkit.py +407 -0
- camel/toolkits/{video_toolkit.py → video_download_toolkit.py} +21 -25
- camel/toolkits/web_toolkit.py +1307 -0
- camel/toolkits/whatsapp_toolkit.py +3 -2
- camel/toolkits/zapier_toolkit.py +191 -0
- camel/types/__init__.py +2 -2
- camel/types/agents/__init__.py +16 -0
- camel/types/agents/tool_calling_record.py +52 -0
- camel/types/enums.py +3 -0
- camel/types/openai_types.py +16 -14
- camel/utils/__init__.py +2 -1
- camel/utils/async_func.py +2 -2
- camel/utils/commons.py +114 -1
- camel/verifiers/__init__.py +23 -0
- camel/verifiers/base.py +340 -0
- camel/verifiers/models.py +82 -0
- camel/verifiers/python_verifier.py +202 -0
- camel_ai-0.2.23.dist-info/METADATA +671 -0
- {camel_ai-0.2.22.dist-info → camel_ai-0.2.23.dist-info}/RECORD +122 -97
- {camel_ai-0.2.22.dist-info → camel_ai-0.2.23.dist-info}/WHEEL +1 -1
- camel_ai-0.2.22.dist-info/METADATA +0 -527
- {camel_ai-0.2.22.dist-info → camel_ai-0.2.23.dist-info/licenses}/LICENSE +0 -0
|
@@ -15,16 +15,20 @@
|
|
|
15
15
|
import json
|
|
16
16
|
import os
|
|
17
17
|
import random
|
|
18
|
+
import time
|
|
18
19
|
from typing import Any, Dict, List, Optional
|
|
19
20
|
|
|
20
21
|
from pydantic import BaseModel, Field
|
|
21
22
|
|
|
22
23
|
from camel.agents import ChatAgent
|
|
24
|
+
from camel.logger import get_logger
|
|
23
25
|
|
|
24
26
|
from .filter import RougeSimilarityFilter
|
|
25
27
|
from .filter.instruction_filter import InstructionFilter
|
|
26
28
|
from .templates import SelfInstructTemplates
|
|
27
29
|
|
|
30
|
+
logger = get_logger(__name__)
|
|
31
|
+
|
|
28
32
|
|
|
29
33
|
class SelfInstructPipeline:
|
|
30
34
|
r"""A pipeline to generate and manage machine-generated instructions for
|
|
@@ -45,6 +49,8 @@ class SelfInstructPipeline:
|
|
|
45
49
|
filter_config (Optional[Dict[str, Dict[str, Any]]]): configuration
|
|
46
50
|
for the filter functions registered in FILE_REGISTRY.
|
|
47
51
|
(default::obj:`None`)
|
|
52
|
+
stop_on_first_failure (bool): If True, stops checking filters after
|
|
53
|
+
the first failure.
|
|
48
54
|
"""
|
|
49
55
|
|
|
50
56
|
def __init__(
|
|
@@ -56,6 +62,7 @@ class SelfInstructPipeline:
|
|
|
56
62
|
human_to_machine_ratio: tuple = (6, 2),
|
|
57
63
|
instruction_filter: Optional[InstructionFilter] = None,
|
|
58
64
|
filter_config: Optional[Dict[str, Dict[str, Any]]] = None,
|
|
65
|
+
stop_on_first_failure: bool = False,
|
|
59
66
|
):
|
|
60
67
|
self.agent = agent
|
|
61
68
|
self.num_machine_instructions = num_machine_instructions
|
|
@@ -80,7 +87,9 @@ class SelfInstructPipeline:
|
|
|
80
87
|
config_to_use = (
|
|
81
88
|
filter_config if filter_config is not None else default_config
|
|
82
89
|
)
|
|
83
|
-
self.instruction_filter = InstructionFilter(
|
|
90
|
+
self.instruction_filter = InstructionFilter(
|
|
91
|
+
config_to_use, stop_on_first_failure
|
|
92
|
+
)
|
|
84
93
|
|
|
85
94
|
def load_seed(self, path: str):
|
|
86
95
|
r"""Load seed tasks from a file. Defaults to a predefined seed file if
|
|
@@ -205,18 +214,28 @@ class SelfInstructPipeline:
|
|
|
205
214
|
)
|
|
206
215
|
return structured_response.answer
|
|
207
216
|
except ValueError as e:
|
|
208
|
-
|
|
217
|
+
logger.error(f"Error parsing agent response: {e}")
|
|
209
218
|
return False
|
|
210
219
|
|
|
211
220
|
def generate_machine_instances(self):
|
|
212
221
|
r"""Generate instances for each machine task based on its
|
|
213
222
|
classification status.
|
|
214
223
|
"""
|
|
224
|
+
logger.info(
|
|
225
|
+
f"Starting output generation: target {len(self.machine_tasks)} "
|
|
226
|
+
f"instructions"
|
|
227
|
+
)
|
|
228
|
+
attempt_count = 0
|
|
215
229
|
for instruction in self.machine_tasks:
|
|
216
230
|
instance = self.generate_machine_instance(
|
|
217
231
|
instruction['instruction'], instruction['is_classification']
|
|
218
232
|
)
|
|
219
233
|
instruction['instances'] = instance
|
|
234
|
+
attempt_count += 1
|
|
235
|
+
logger.info(
|
|
236
|
+
f"Attempt[Output]: Progress {attempt_count}/"
|
|
237
|
+
f"{len(self.machine_tasks)} instructions"
|
|
238
|
+
)
|
|
220
239
|
|
|
221
240
|
def generate_machine_instance(
|
|
222
241
|
self, instruction: str, classification: bool
|
|
@@ -363,11 +382,30 @@ class SelfInstructPipeline:
|
|
|
363
382
|
with open(self.data_output_path, 'w') as f:
|
|
364
383
|
json.dump(self.machine_tasks, f, indent=4, ensure_ascii=False)
|
|
365
384
|
|
|
366
|
-
def generate(self):
|
|
385
|
+
def generate(self, timeout_minutes=600):
|
|
367
386
|
r"""Execute the entire pipeline to generate machine instructions
|
|
368
387
|
and instances.
|
|
388
|
+
|
|
389
|
+
Args:
|
|
390
|
+
timeout_minutes (int): Maximum time in minutes to run the
|
|
391
|
+
generation process before timing out. (default: :obj:`600`)
|
|
369
392
|
"""
|
|
393
|
+
start_time = time.time()
|
|
394
|
+
timeout_seconds = timeout_minutes * 60
|
|
395
|
+
logger.info(
|
|
396
|
+
f"Starting instruction generation: target "
|
|
397
|
+
f"{self.num_machine_instructions} instructions"
|
|
398
|
+
)
|
|
370
399
|
while len(self.machine_tasks) < self.num_machine_instructions:
|
|
400
|
+
# Check for timeout
|
|
401
|
+
elapsed = time.time() - start_time
|
|
402
|
+
if elapsed > timeout_seconds:
|
|
403
|
+
logger.info(
|
|
404
|
+
f"Generation timed out after {elapsed / 60:.1f} minutes. "
|
|
405
|
+
f"Generated {len(self.machine_tasks)}/"
|
|
406
|
+
f"{self.num_machine_instructions} instructions."
|
|
407
|
+
)
|
|
408
|
+
break
|
|
371
409
|
prompt, instruction = self.generate_machine_instruction()
|
|
372
410
|
existing_instructions = [
|
|
373
411
|
t["instruction"] for t in self.human_tasks
|
|
@@ -384,6 +422,17 @@ class SelfInstructPipeline:
|
|
|
384
422
|
),
|
|
385
423
|
}
|
|
386
424
|
self.machine_tasks.append(instruction_dict)
|
|
425
|
+
logger.info(
|
|
426
|
+
f"Attempt[Instruction]: Progress "
|
|
427
|
+
f"{len(self.machine_tasks)}/"
|
|
428
|
+
f"{self.num_machine_instructions} "
|
|
429
|
+
f"instructions"
|
|
430
|
+
)
|
|
431
|
+
else:
|
|
432
|
+
logger.warning(
|
|
433
|
+
f"Instruction failed filters. Skipping instruction: "
|
|
434
|
+
f"{instruction}"
|
|
435
|
+
)
|
|
387
436
|
self.generate_machine_instances()
|
|
388
437
|
self.construct_data()
|
|
389
438
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
# See the License for the specific language governing permissions and
|
|
12
|
+
# limitations under the License.
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
|
+
from .base import (
|
|
15
|
+
BaseDataset,
|
|
16
|
+
DataPoint,
|
|
17
|
+
GenerativeDataset,
|
|
18
|
+
SeedDataset,
|
|
19
|
+
SyntheticDataset,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"DataPoint",
|
|
24
|
+
"BaseDataset",
|
|
25
|
+
"SeedDataset",
|
|
26
|
+
"GenerativeDataset",
|
|
27
|
+
"SyntheticDataset",
|
|
28
|
+
]
|