camel-ai 0.2.3a1__py3-none-any.whl → 0.2.4__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/chat_agent.py +93 -69
- camel/agents/knowledge_graph_agent.py +4 -6
- camel/bots/__init__.py +16 -2
- camel/bots/discord_app.py +138 -0
- camel/bots/slack/__init__.py +30 -0
- camel/bots/slack/models.py +158 -0
- camel/bots/slack/slack_app.py +255 -0
- camel/configs/__init__.py +1 -2
- camel/configs/anthropic_config.py +2 -5
- camel/configs/base_config.py +6 -6
- camel/configs/groq_config.py +2 -3
- camel/configs/ollama_config.py +1 -2
- camel/configs/openai_config.py +2 -23
- camel/configs/samba_config.py +2 -2
- camel/configs/togetherai_config.py +1 -1
- camel/configs/vllm_config.py +1 -1
- camel/configs/zhipuai_config.py +2 -3
- camel/embeddings/openai_embedding.py +2 -2
- camel/loaders/__init__.py +2 -0
- camel/loaders/chunkr_reader.py +163 -0
- camel/loaders/firecrawl_reader.py +3 -3
- camel/loaders/unstructured_io.py +35 -33
- camel/messages/__init__.py +1 -0
- camel/models/__init__.py +2 -4
- camel/models/anthropic_model.py +32 -26
- camel/models/azure_openai_model.py +39 -36
- camel/models/base_model.py +31 -20
- camel/models/gemini_model.py +37 -29
- camel/models/groq_model.py +29 -23
- camel/models/litellm_model.py +44 -61
- camel/models/mistral_model.py +32 -29
- camel/models/model_factory.py +66 -76
- camel/models/nemotron_model.py +33 -23
- camel/models/ollama_model.py +42 -47
- camel/models/{openai_compatibility_model.py → openai_compatible_model.py} +31 -49
- camel/models/openai_model.py +48 -29
- camel/models/reka_model.py +30 -28
- camel/models/samba_model.py +82 -177
- camel/models/stub_model.py +2 -2
- camel/models/togetherai_model.py +37 -43
- camel/models/vllm_model.py +43 -50
- camel/models/zhipuai_model.py +33 -27
- camel/retrievers/auto_retriever.py +29 -97
- camel/retrievers/vector_retriever.py +58 -47
- camel/societies/babyagi_playing.py +6 -3
- camel/societies/role_playing.py +5 -3
- camel/storages/graph_storages/graph_element.py +2 -2
- camel/storages/key_value_storages/json.py +6 -1
- camel/toolkits/__init__.py +20 -7
- camel/toolkits/arxiv_toolkit.py +155 -0
- camel/toolkits/ask_news_toolkit.py +653 -0
- camel/toolkits/base.py +2 -3
- camel/toolkits/code_execution.py +6 -7
- camel/toolkits/dalle_toolkit.py +6 -6
- camel/toolkits/{openai_function.py → function_tool.py} +34 -11
- camel/toolkits/github_toolkit.py +9 -10
- camel/toolkits/google_maps_toolkit.py +7 -7
- camel/toolkits/google_scholar_toolkit.py +146 -0
- camel/toolkits/linkedin_toolkit.py +7 -7
- camel/toolkits/math_toolkit.py +8 -8
- camel/toolkits/open_api_toolkit.py +5 -5
- camel/toolkits/reddit_toolkit.py +7 -7
- camel/toolkits/retrieval_toolkit.py +5 -5
- camel/toolkits/search_toolkit.py +9 -9
- camel/toolkits/slack_toolkit.py +11 -11
- camel/toolkits/twitter_toolkit.py +378 -452
- camel/toolkits/weather_toolkit.py +6 -6
- camel/toolkits/whatsapp_toolkit.py +177 -0
- camel/types/__init__.py +6 -1
- camel/types/enums.py +40 -85
- camel/types/openai_types.py +3 -0
- camel/types/unified_model_type.py +104 -0
- camel/utils/__init__.py +0 -2
- camel/utils/async_func.py +7 -7
- camel/utils/commons.py +32 -3
- camel/utils/token_counting.py +30 -212
- camel/workforce/role_playing_worker.py +1 -1
- camel/workforce/single_agent_worker.py +1 -1
- camel/workforce/task_channel.py +4 -3
- camel/workforce/workforce.py +4 -4
- camel_ai-0.2.4.dist-info/LICENSE +201 -0
- {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/METADATA +27 -56
- {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/RECORD +85 -76
- {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/WHEEL +1 -1
- camel/bots/discord_bot.py +0 -206
- camel/models/open_source_model.py +0 -170
camel/utils/commons.py
CHANGED
|
@@ -257,18 +257,18 @@ def api_keys_required(*required_keys: str) -> Callable[[F], F]:
|
|
|
257
257
|
|
|
258
258
|
def decorator(func: F) -> F:
|
|
259
259
|
@wraps(func)
|
|
260
|
-
def wrapper(
|
|
260
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
261
261
|
missing_environment_keys = [
|
|
262
262
|
k for k in required_keys if k not in os.environ
|
|
263
263
|
]
|
|
264
264
|
if (
|
|
265
|
-
not getattr(
|
|
265
|
+
not (args and getattr(args[0], '_api_key', None))
|
|
266
266
|
and missing_environment_keys
|
|
267
267
|
):
|
|
268
268
|
raise ValueError(
|
|
269
269
|
f"Missing API keys: {', '.join(missing_environment_keys)}"
|
|
270
270
|
)
|
|
271
|
-
return func(
|
|
271
|
+
return func(*args, **kwargs)
|
|
272
272
|
|
|
273
273
|
return cast(F, wrapper)
|
|
274
274
|
|
|
@@ -577,3 +577,32 @@ def handle_http_error(response: requests.Response) -> str:
|
|
|
577
577
|
return "Too Many Requests. You have hit the rate limit."
|
|
578
578
|
else:
|
|
579
579
|
return "HTTP Error"
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
def retry_request(
|
|
583
|
+
func: Callable, retries: int = 3, delay: int = 1, *args: Any, **kwargs: Any
|
|
584
|
+
) -> Any:
|
|
585
|
+
r"""Retries a function in case of any errors.
|
|
586
|
+
|
|
587
|
+
Args:
|
|
588
|
+
func (Callable): The function to be retried.
|
|
589
|
+
retries (int): Number of retry attempts. (default: :obj:`3`)
|
|
590
|
+
delay (int): Delay between retries in seconds. (default: :obj:`1`)
|
|
591
|
+
*args: Arguments to pass to the function.
|
|
592
|
+
**kwargs: Keyword arguments to pass to the function.
|
|
593
|
+
|
|
594
|
+
Returns:
|
|
595
|
+
Any: The result of the function call if successful.
|
|
596
|
+
|
|
597
|
+
Raises:
|
|
598
|
+
Exception: If all retry attempts fail.
|
|
599
|
+
"""
|
|
600
|
+
for attempt in range(retries):
|
|
601
|
+
try:
|
|
602
|
+
return func(*args, **kwargs)
|
|
603
|
+
except Exception as e:
|
|
604
|
+
print(f"Attempt {attempt + 1}/{retries} failed: {e}")
|
|
605
|
+
if attempt < retries - 1:
|
|
606
|
+
time.sleep(delay)
|
|
607
|
+
else:
|
|
608
|
+
raise
|
camel/utils/token_counting.py
CHANGED
|
@@ -20,10 +20,15 @@ from io import BytesIO
|
|
|
20
20
|
from math import ceil
|
|
21
21
|
from typing import TYPE_CHECKING, List, Optional
|
|
22
22
|
|
|
23
|
-
from anthropic import Anthropic
|
|
24
23
|
from PIL import Image
|
|
25
24
|
|
|
26
|
-
from camel.types import
|
|
25
|
+
from camel.types import (
|
|
26
|
+
ModelType,
|
|
27
|
+
OpenAIImageType,
|
|
28
|
+
OpenAIVisionDetailType,
|
|
29
|
+
UnifiedModelType,
|
|
30
|
+
)
|
|
31
|
+
from camel.utils import dependencies_required
|
|
27
32
|
|
|
28
33
|
if TYPE_CHECKING:
|
|
29
34
|
from mistral_common.protocol.instruct.request import ( # type:ignore[import-not-found]
|
|
@@ -40,145 +45,6 @@ SQUARE_TOKENS = 170
|
|
|
40
45
|
EXTRA_TOKENS = 85
|
|
41
46
|
|
|
42
47
|
|
|
43
|
-
def messages_to_prompt(messages: List[OpenAIMessage], model: ModelType) -> str:
|
|
44
|
-
r"""Parse the message list into a single prompt following model-specific
|
|
45
|
-
formats.
|
|
46
|
-
|
|
47
|
-
Args:
|
|
48
|
-
messages (List[OpenAIMessage]): Message list with the chat history
|
|
49
|
-
in OpenAI API format.
|
|
50
|
-
model (ModelType): Model type for which messages will be parsed.
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
str: A single prompt summarizing all the messages.
|
|
54
|
-
"""
|
|
55
|
-
system_message = messages[0]["content"]
|
|
56
|
-
|
|
57
|
-
ret: str
|
|
58
|
-
if model in [
|
|
59
|
-
ModelType.LLAMA_2,
|
|
60
|
-
ModelType.LLAMA_3,
|
|
61
|
-
ModelType.GROQ_LLAMA_3_8B,
|
|
62
|
-
ModelType.GROQ_LLAMA_3_70B,
|
|
63
|
-
]:
|
|
64
|
-
# reference: https://github.com/facebookresearch/llama/blob/cfc3fc8c1968d390eb830e65c63865e980873a06/llama/generation.py#L212
|
|
65
|
-
seps = [" ", " </s><s>"]
|
|
66
|
-
role_map = {"user": "[INST]", "assistant": "[/INST]"}
|
|
67
|
-
|
|
68
|
-
system_prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n"
|
|
69
|
-
ret = ""
|
|
70
|
-
for i, msg in enumerate(messages[1:]):
|
|
71
|
-
role = role_map[msg["role"]]
|
|
72
|
-
content = msg["content"]
|
|
73
|
-
if content:
|
|
74
|
-
if not isinstance(content, str):
|
|
75
|
-
raise ValueError(
|
|
76
|
-
"Currently multimodal context is not "
|
|
77
|
-
"supported by the token counter."
|
|
78
|
-
)
|
|
79
|
-
if i == 0:
|
|
80
|
-
ret += system_prompt + content
|
|
81
|
-
else:
|
|
82
|
-
ret += role + " " + content + seps[i % 2]
|
|
83
|
-
else:
|
|
84
|
-
ret += role
|
|
85
|
-
return ret
|
|
86
|
-
elif model in [ModelType.VICUNA, ModelType.VICUNA_16K]:
|
|
87
|
-
seps = [" ", "</s>"]
|
|
88
|
-
role_map = {"user": "USER", "assistant": "ASSISTANT"}
|
|
89
|
-
|
|
90
|
-
system_prompt = f"{system_message}"
|
|
91
|
-
ret = system_prompt + seps[0]
|
|
92
|
-
for i, msg in enumerate(messages[1:]):
|
|
93
|
-
role = role_map[msg["role"]]
|
|
94
|
-
content = msg["content"]
|
|
95
|
-
if not isinstance(content, str):
|
|
96
|
-
raise ValueError(
|
|
97
|
-
"Currently multimodal context is not "
|
|
98
|
-
"supported by the token counter."
|
|
99
|
-
)
|
|
100
|
-
if content:
|
|
101
|
-
ret += role + ": " + content + seps[i % 2]
|
|
102
|
-
else:
|
|
103
|
-
ret += role + ":"
|
|
104
|
-
return ret
|
|
105
|
-
elif model == ModelType.GLM_4_OPEN_SOURCE:
|
|
106
|
-
system_prompt = f"[gMASK]<sop><|system|>\n{system_message}"
|
|
107
|
-
ret = system_prompt
|
|
108
|
-
for msg in messages[1:]:
|
|
109
|
-
role = msg["role"]
|
|
110
|
-
content = msg["content"]
|
|
111
|
-
if not isinstance(content, str):
|
|
112
|
-
raise ValueError(
|
|
113
|
-
"Currently multimodal context is not "
|
|
114
|
-
"supported by the token counter."
|
|
115
|
-
)
|
|
116
|
-
if content:
|
|
117
|
-
ret += "<|" + role + "|>" + "\n" + content
|
|
118
|
-
else:
|
|
119
|
-
ret += "<|" + role + "|>" + "\n"
|
|
120
|
-
return ret
|
|
121
|
-
elif model == ModelType.QWEN_2:
|
|
122
|
-
system_prompt = f"<|im_start|>system\n{system_message}<|im_end|>"
|
|
123
|
-
ret = system_prompt + "\n"
|
|
124
|
-
for msg in messages[1:]:
|
|
125
|
-
role = msg["role"]
|
|
126
|
-
content = msg["content"]
|
|
127
|
-
if not isinstance(content, str):
|
|
128
|
-
raise ValueError(
|
|
129
|
-
"Currently multimodal context is not "
|
|
130
|
-
"supported by the token counter."
|
|
131
|
-
)
|
|
132
|
-
if content:
|
|
133
|
-
ret += (
|
|
134
|
-
'<|im_start|>'
|
|
135
|
-
+ role
|
|
136
|
-
+ '\n'
|
|
137
|
-
+ content
|
|
138
|
-
+ '<|im_end|>'
|
|
139
|
-
+ '\n'
|
|
140
|
-
)
|
|
141
|
-
else:
|
|
142
|
-
ret += '<|im_start|>' + role + '\n'
|
|
143
|
-
return ret
|
|
144
|
-
elif model == ModelType.GROQ_MIXTRAL_8_7B:
|
|
145
|
-
# Mistral/Mixtral format
|
|
146
|
-
system_prompt = f"<s>[INST] {system_message} [/INST]\n"
|
|
147
|
-
ret = system_prompt
|
|
148
|
-
|
|
149
|
-
for msg in messages[1:]:
|
|
150
|
-
if msg["role"] == "user":
|
|
151
|
-
ret += f"[INST] {msg['content']} [/INST]\n"
|
|
152
|
-
elif msg["role"] == "assistant":
|
|
153
|
-
ret += f"{msg['content']}</s>\n"
|
|
154
|
-
|
|
155
|
-
if not isinstance(msg['content'], str):
|
|
156
|
-
raise ValueError(
|
|
157
|
-
"Currently multimodal context is not "
|
|
158
|
-
"supported by the token counter."
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
return ret.strip()
|
|
162
|
-
elif model in [ModelType.GROQ_GEMMA_7B_IT, ModelType.GROQ_GEMMA_2_9B_IT]:
|
|
163
|
-
# Gemma format
|
|
164
|
-
ret = f"<bos>{system_message}\n"
|
|
165
|
-
for msg in messages:
|
|
166
|
-
if msg["role"] == "user":
|
|
167
|
-
ret += f"Human: {msg['content']}\n"
|
|
168
|
-
elif msg["role"] == "assistant":
|
|
169
|
-
ret += f"Assistant: {msg['content']}\n"
|
|
170
|
-
|
|
171
|
-
if not isinstance(msg['content'], str):
|
|
172
|
-
raise ValueError(
|
|
173
|
-
"Currently multimodal context is not supported by the token counter."
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
ret += "<eos>"
|
|
177
|
-
return ret
|
|
178
|
-
else:
|
|
179
|
-
raise ValueError(f"Invalid model type: {model}")
|
|
180
|
-
|
|
181
|
-
|
|
182
48
|
def get_model_encoding(value_for_tiktoken: str):
|
|
183
49
|
r"""Get model encoding from tiktoken.
|
|
184
50
|
|
|
@@ -221,67 +87,15 @@ class BaseTokenCounter(ABC):
|
|
|
221
87
|
pass
|
|
222
88
|
|
|
223
89
|
|
|
224
|
-
class OpenSourceTokenCounter(BaseTokenCounter):
|
|
225
|
-
def __init__(self, model_type: ModelType, model_path: str):
|
|
226
|
-
r"""Constructor for the token counter for open-source models.
|
|
227
|
-
|
|
228
|
-
Args:
|
|
229
|
-
model_type (ModelType): Model type for which tokens will be
|
|
230
|
-
counted.
|
|
231
|
-
model_path (str): The path to the model files, where the tokenizer
|
|
232
|
-
model should be located.
|
|
233
|
-
"""
|
|
234
|
-
|
|
235
|
-
# Use a fast Rust-based tokenizer if it is supported for a given model.
|
|
236
|
-
# If a fast tokenizer is not available for a given model,
|
|
237
|
-
# a normal Python-based tokenizer is returned instead.
|
|
238
|
-
from transformers import AutoTokenizer
|
|
239
|
-
|
|
240
|
-
try:
|
|
241
|
-
tokenizer = AutoTokenizer.from_pretrained(
|
|
242
|
-
model_path,
|
|
243
|
-
use_fast=True,
|
|
244
|
-
)
|
|
245
|
-
except TypeError:
|
|
246
|
-
tokenizer = AutoTokenizer.from_pretrained(
|
|
247
|
-
model_path,
|
|
248
|
-
use_fast=False,
|
|
249
|
-
)
|
|
250
|
-
except Exception:
|
|
251
|
-
raise ValueError(
|
|
252
|
-
f"Invalid `model_path` ({model_path}) is provided. "
|
|
253
|
-
"Tokenizer loading failed."
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
self.tokenizer = tokenizer
|
|
257
|
-
self.model_type = model_type
|
|
258
|
-
|
|
259
|
-
def count_tokens_from_messages(self, messages: List[OpenAIMessage]) -> int:
|
|
260
|
-
r"""Count number of tokens in the provided message list using
|
|
261
|
-
loaded tokenizer specific for this type of model.
|
|
262
|
-
|
|
263
|
-
Args:
|
|
264
|
-
messages (List[OpenAIMessage]): Message list with the chat history
|
|
265
|
-
in OpenAI API format.
|
|
266
|
-
|
|
267
|
-
Returns:
|
|
268
|
-
int: Number of tokens in the messages.
|
|
269
|
-
"""
|
|
270
|
-
prompt = messages_to_prompt(messages, self.model_type)
|
|
271
|
-
input_ids = self.tokenizer(prompt).input_ids
|
|
272
|
-
|
|
273
|
-
return len(input_ids)
|
|
274
|
-
|
|
275
|
-
|
|
276
90
|
class OpenAITokenCounter(BaseTokenCounter):
|
|
277
|
-
def __init__(self, model:
|
|
91
|
+
def __init__(self, model: UnifiedModelType):
|
|
278
92
|
r"""Constructor for the token counter for OpenAI models.
|
|
279
93
|
|
|
280
94
|
Args:
|
|
281
|
-
model (
|
|
95
|
+
model (UnifiedModelType): Model type for which tokens will be
|
|
96
|
+
counted.
|
|
282
97
|
"""
|
|
283
98
|
self.model: str = model.value_for_tiktoken
|
|
284
|
-
self.model_type = model
|
|
285
99
|
|
|
286
100
|
self.tokens_per_message: int
|
|
287
101
|
self.tokens_per_name: int
|
|
@@ -404,15 +218,11 @@ class OpenAITokenCounter(BaseTokenCounter):
|
|
|
404
218
|
|
|
405
219
|
|
|
406
220
|
class AnthropicTokenCounter(BaseTokenCounter):
|
|
407
|
-
|
|
408
|
-
|
|
221
|
+
@dependencies_required('anthropic')
|
|
222
|
+
def __init__(self):
|
|
223
|
+
r"""Constructor for the token counter for Anthropic models."""
|
|
224
|
+
from anthropic import Anthropic
|
|
409
225
|
|
|
410
|
-
Args:
|
|
411
|
-
model_type (ModelType): Model type for which tokens will be
|
|
412
|
-
counted.
|
|
413
|
-
"""
|
|
414
|
-
|
|
415
|
-
self.model_type = model_type
|
|
416
226
|
self.client = Anthropic()
|
|
417
227
|
self.tokenizer = self.client.get_tokenizer()
|
|
418
228
|
|
|
@@ -435,12 +245,16 @@ class AnthropicTokenCounter(BaseTokenCounter):
|
|
|
435
245
|
|
|
436
246
|
|
|
437
247
|
class GeminiTokenCounter(BaseTokenCounter):
|
|
438
|
-
def __init__(self, model_type:
|
|
439
|
-
r"""Constructor for the token counter for Gemini models.
|
|
248
|
+
def __init__(self, model_type: UnifiedModelType):
|
|
249
|
+
r"""Constructor for the token counter for Gemini models.
|
|
250
|
+
|
|
251
|
+
Args:
|
|
252
|
+
model_type (UnifiedModelType): Model type for which tokens will be
|
|
253
|
+
counted.
|
|
254
|
+
"""
|
|
440
255
|
import google.generativeai as genai
|
|
441
256
|
|
|
442
|
-
self.
|
|
443
|
-
self._client = genai.GenerativeModel(self.model_type.value)
|
|
257
|
+
self._client = genai.GenerativeModel(model_type)
|
|
444
258
|
|
|
445
259
|
def count_tokens_from_messages(self, messages: List[OpenAIMessage]) -> int:
|
|
446
260
|
r"""Count number of tokens in the provided message list using
|
|
@@ -468,12 +282,13 @@ class GeminiTokenCounter(BaseTokenCounter):
|
|
|
468
282
|
return self._client.count_tokens(converted_messages).total_tokens
|
|
469
283
|
|
|
470
284
|
|
|
471
|
-
class LiteLLMTokenCounter:
|
|
472
|
-
def __init__(self, model_type:
|
|
285
|
+
class LiteLLMTokenCounter(BaseTokenCounter):
|
|
286
|
+
def __init__(self, model_type: UnifiedModelType):
|
|
473
287
|
r"""Constructor for the token counter for LiteLLM models.
|
|
474
288
|
|
|
475
289
|
Args:
|
|
476
|
-
model_type (
|
|
290
|
+
model_type (UnifiedModelType): Model type for which tokens will be
|
|
291
|
+
counted.
|
|
477
292
|
"""
|
|
478
293
|
self.model_type = model_type
|
|
479
294
|
self._token_counter = None
|
|
@@ -538,7 +353,10 @@ class MistralTokenCounter(BaseTokenCounter):
|
|
|
538
353
|
model_name = (
|
|
539
354
|
"codestral-22b"
|
|
540
355
|
if self.model_type
|
|
541
|
-
in {
|
|
356
|
+
in {
|
|
357
|
+
ModelType.MISTRAL_CODESTRAL,
|
|
358
|
+
ModelType.MISTRAL_CODESTRAL_MAMBA,
|
|
359
|
+
}
|
|
542
360
|
else self.model_type.value
|
|
543
361
|
)
|
|
544
362
|
|
|
@@ -172,7 +172,7 @@ class RolePlayingWorker(Worker):
|
|
|
172
172
|
role_name="User",
|
|
173
173
|
content=prompt,
|
|
174
174
|
)
|
|
175
|
-
response = self.summarize_agent.step(req,
|
|
175
|
+
response = self.summarize_agent.step(req, response_format=TaskResult)
|
|
176
176
|
result_dict = ast.literal_eval(response.msg.content)
|
|
177
177
|
task_result = TaskResult(**result_dict)
|
|
178
178
|
task.result = task_result.content
|
|
@@ -77,7 +77,7 @@ class SingleAgentWorker(Worker):
|
|
|
77
77
|
content=prompt,
|
|
78
78
|
)
|
|
79
79
|
try:
|
|
80
|
-
response = self.worker.step(req,
|
|
80
|
+
response = self.worker.step(req, response_format=TaskResult)
|
|
81
81
|
except Exception as e:
|
|
82
82
|
print(
|
|
83
83
|
f"{Fore.RED}Error occurred while processing task {task.id}:"
|
camel/workforce/task_channel.py
CHANGED
|
@@ -21,12 +21,13 @@ from camel.tasks import Task
|
|
|
21
21
|
class PacketStatus(Enum):
|
|
22
22
|
r"""The status of a packet. The packet can be in one of the following
|
|
23
23
|
states:
|
|
24
|
+
|
|
24
25
|
- ``SENT``: The packet has been sent to a worker.
|
|
25
26
|
- ``RETURNED``: The packet has been returned by the worker, meaning that
|
|
26
|
-
|
|
27
|
+
the status of the task inside has been updated.
|
|
27
28
|
- ``ARCHIVED``: The packet has been archived, meaning that the content of
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
the task inside will not be changed. The task is considered
|
|
30
|
+
as a dependency.
|
|
30
31
|
"""
|
|
31
32
|
|
|
32
33
|
SENT = "SENT"
|
camel/workforce/workforce.py
CHANGED
|
@@ -287,7 +287,7 @@ class Workforce(BaseNode):
|
|
|
287
287
|
)
|
|
288
288
|
|
|
289
289
|
response = self.coordinator_agent.step(
|
|
290
|
-
req,
|
|
290
|
+
req, response_format=TaskAssignResult
|
|
291
291
|
)
|
|
292
292
|
result_dict = ast.literal_eval(response.msg.content)
|
|
293
293
|
task_assign_result = TaskAssignResult(**result_dict)
|
|
@@ -319,7 +319,7 @@ class Workforce(BaseNode):
|
|
|
319
319
|
role_name="User",
|
|
320
320
|
content=prompt,
|
|
321
321
|
)
|
|
322
|
-
response = self.coordinator_agent.step(req,
|
|
322
|
+
response = self.coordinator_agent.step(req, response_format=WorkerConf)
|
|
323
323
|
result_dict = ast.literal_eval(response.msg.content)
|
|
324
324
|
new_node_conf = WorkerConf(**result_dict)
|
|
325
325
|
|
|
@@ -364,8 +364,8 @@ class Workforce(BaseNode):
|
|
|
364
364
|
).as_dict()
|
|
365
365
|
|
|
366
366
|
model = ModelFactory.create(
|
|
367
|
-
model_platform=ModelPlatformType.
|
|
368
|
-
model_type=ModelType.
|
|
367
|
+
model_platform=ModelPlatformType.DEFAULT,
|
|
368
|
+
model_type=ModelType.DEFAULT,
|
|
369
369
|
model_config_dict=model_config_dict,
|
|
370
370
|
)
|
|
371
371
|
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2023 @ CAMEL-AI.org
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|