camel-ai 0.2.9__py3-none-any.whl → 0.2.10__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 +5 -5
- camel/agents/__init__.py +4 -4
- camel/agents/base.py +4 -4
- camel/agents/chat_agent.py +32 -37
- camel/agents/critic_agent.py +4 -4
- camel/agents/deductive_reasoner_agent.py +4 -4
- camel/agents/embodied_agent.py +4 -4
- camel/agents/knowledge_graph_agent.py +4 -4
- camel/agents/role_assignment_agent.py +4 -4
- camel/agents/search_agent.py +4 -4
- camel/agents/task_agent.py +4 -4
- camel/agents/tool_agents/__init__.py +4 -4
- camel/agents/tool_agents/base.py +4 -4
- camel/agents/tool_agents/hugging_face_tool_agent.py +4 -4
- camel/bots/__init__.py +4 -4
- camel/bots/discord_app.py +4 -4
- camel/bots/slack/__init__.py +4 -4
- camel/bots/slack/models.py +4 -4
- camel/bots/slack/slack_app.py +4 -4
- camel/bots/telegram_bot.py +4 -4
- camel/configs/__init__.py +10 -4
- camel/configs/anthropic_config.py +4 -4
- camel/configs/base_config.py +4 -4
- camel/configs/cohere_config.py +76 -0
- camel/configs/deepseek_config.py +134 -0
- camel/configs/gemini_config.py +85 -127
- camel/configs/groq_config.py +4 -4
- camel/configs/litellm_config.py +4 -4
- camel/configs/mistral_config.py +4 -4
- camel/configs/ollama_config.py +4 -4
- camel/configs/openai_config.py +32 -7
- camel/configs/qwen_config.py +4 -4
- camel/configs/reka_config.py +4 -4
- camel/configs/samba_config.py +4 -4
- camel/configs/togetherai_config.py +4 -4
- camel/configs/vllm_config.py +4 -4
- camel/configs/yi_config.py +4 -4
- camel/configs/zhipuai_config.py +4 -4
- camel/embeddings/__init__.py +6 -4
- camel/embeddings/base.py +4 -4
- camel/embeddings/mistral_embedding.py +4 -4
- camel/embeddings/openai_compatible_embedding.py +91 -0
- camel/embeddings/openai_embedding.py +4 -4
- camel/embeddings/sentence_transformers_embeddings.py +4 -4
- camel/embeddings/vlm_embedding.py +4 -4
- camel/generators.py +4 -4
- camel/human.py +4 -4
- camel/interpreters/__init__.py +4 -4
- camel/interpreters/base.py +4 -4
- camel/interpreters/docker_interpreter.py +4 -4
- camel/interpreters/internal_python_interpreter.py +4 -4
- camel/interpreters/interpreter_error.py +4 -4
- camel/interpreters/ipython_interpreter.py +4 -4
- camel/interpreters/subprocess_interpreter.py +4 -4
- camel/loaders/__init__.py +4 -4
- camel/loaders/apify_reader.py +4 -4
- camel/loaders/base_io.py +4 -4
- camel/loaders/chunkr_reader.py +4 -4
- camel/loaders/firecrawl_reader.py +4 -4
- camel/loaders/jina_url_reader.py +4 -4
- camel/loaders/unstructured_io.py +4 -4
- camel/memories/__init__.py +4 -4
- camel/memories/agent_memories.py +4 -4
- camel/memories/base.py +4 -4
- camel/memories/blocks/__init__.py +4 -4
- camel/memories/blocks/chat_history_block.py +4 -4
- camel/memories/blocks/vectordb_block.py +4 -4
- camel/memories/context_creators/__init__.py +4 -4
- camel/memories/context_creators/score_based.py +4 -4
- camel/memories/records.py +4 -4
- camel/messages/__init__.py +20 -4
- camel/messages/base.py +108 -4
- camel/messages/conversion/__init__.py +29 -0
- camel/messages/conversion/models.py +178 -0
- camel/messages/conversion/sharegpt/__init__.py +20 -0
- camel/messages/conversion/sharegpt/function_call_formatter.py +49 -0
- camel/messages/conversion/sharegpt/hermes/__init__.py +19 -0
- camel/messages/conversion/sharegpt/hermes/hermes_function_formatter.py +128 -0
- camel/messages/func_message.py +50 -4
- camel/models/__init__.py +8 -4
- camel/models/anthropic_model.py +4 -4
- camel/models/azure_openai_model.py +4 -4
- camel/models/base_model.py +4 -4
- camel/models/cohere_model.py +282 -0
- camel/models/deepseek_model.py +139 -0
- camel/models/gemini_model.py +61 -146
- camel/models/groq_model.py +4 -4
- camel/models/litellm_model.py +4 -4
- camel/models/mistral_model.py +4 -4
- camel/models/model_factory.py +10 -4
- camel/models/nemotron_model.py +4 -4
- camel/models/ollama_model.py +4 -4
- camel/models/openai_audio_models.py +4 -4
- camel/models/openai_compatible_model.py +4 -4
- camel/models/openai_model.py +42 -4
- camel/models/qwen_model.py +4 -4
- camel/models/reka_model.py +4 -4
- camel/models/samba_model.py +6 -5
- camel/models/stub_model.py +4 -4
- camel/models/togetherai_model.py +4 -4
- camel/models/vllm_model.py +4 -4
- camel/models/yi_model.py +4 -4
- camel/models/zhipuai_model.py +4 -4
- camel/personas/__init__.py +17 -0
- camel/personas/persona.py +103 -0
- camel/personas/persona_hub.py +293 -0
- camel/prompts/__init__.py +6 -4
- camel/prompts/ai_society.py +4 -4
- camel/prompts/base.py +4 -4
- camel/prompts/code.py +4 -4
- camel/prompts/evaluation.py +4 -4
- camel/prompts/generate_text_embedding_data.py +4 -4
- camel/prompts/image_craft.py +4 -4
- camel/prompts/misalignment.py +4 -4
- camel/prompts/multi_condition_image_craft.py +4 -4
- camel/prompts/object_recognition.py +4 -4
- camel/prompts/persona_hub.py +61 -0
- camel/prompts/prompt_templates.py +4 -4
- camel/prompts/role_description_prompt_template.py +4 -4
- camel/prompts/solution_extraction.py +4 -4
- camel/prompts/task_prompt_template.py +4 -4
- camel/prompts/translation.py +4 -4
- camel/prompts/video_description_prompt.py +4 -4
- camel/responses/__init__.py +4 -4
- camel/responses/agent_responses.py +4 -4
- camel/retrievers/__init__.py +4 -4
- camel/retrievers/auto_retriever.py +4 -4
- camel/retrievers/base.py +4 -4
- camel/retrievers/bm25_retriever.py +4 -4
- camel/retrievers/cohere_rerank_retriever.py +7 -9
- camel/retrievers/vector_retriever.py +4 -4
- camel/runtime/__init__.py +29 -0
- camel/runtime/api.py +93 -0
- camel/runtime/base.py +45 -0
- camel/runtime/configs.py +56 -0
- camel/runtime/docker_runtime.py +404 -0
- camel/runtime/llm_guard_runtime.py +199 -0
- camel/runtime/remote_http_runtime.py +204 -0
- camel/runtime/utils/__init__.py +20 -0
- camel/runtime/utils/function_risk_toolkit.py +58 -0
- camel/runtime/utils/ignore_risk_toolkit.py +72 -0
- camel/schemas/__init__.py +17 -0
- camel/schemas/base.py +45 -0
- camel/schemas/openai_converter.py +116 -0
- camel/societies/__init__.py +4 -4
- camel/societies/babyagi_playing.py +4 -4
- camel/societies/role_playing.py +4 -4
- camel/societies/workforce/__init__.py +4 -4
- camel/societies/workforce/base.py +4 -4
- camel/societies/workforce/prompts.py +4 -4
- camel/societies/workforce/role_playing_worker.py +4 -4
- camel/societies/workforce/single_agent_worker.py +4 -4
- camel/societies/workforce/task_channel.py +4 -4
- camel/societies/workforce/utils.py +4 -4
- camel/societies/workforce/worker.py +4 -4
- camel/societies/workforce/workforce.py +7 -7
- camel/storages/__init__.py +4 -4
- camel/storages/graph_storages/__init__.py +4 -4
- camel/storages/graph_storages/base.py +4 -4
- camel/storages/graph_storages/graph_element.py +4 -4
- camel/storages/graph_storages/nebula_graph.py +4 -4
- camel/storages/graph_storages/neo4j_graph.py +4 -4
- camel/storages/key_value_storages/__init__.py +4 -4
- camel/storages/key_value_storages/base.py +4 -4
- camel/storages/key_value_storages/in_memory.py +4 -4
- camel/storages/key_value_storages/json.py +4 -4
- camel/storages/key_value_storages/redis.py +4 -4
- camel/storages/object_storages/__init__.py +4 -4
- camel/storages/object_storages/amazon_s3.py +4 -4
- camel/storages/object_storages/azure_blob.py +4 -4
- camel/storages/object_storages/base.py +4 -4
- camel/storages/object_storages/google_cloud.py +4 -4
- camel/storages/vectordb_storages/__init__.py +4 -4
- camel/storages/vectordb_storages/base.py +4 -4
- camel/storages/vectordb_storages/milvus.py +4 -4
- camel/storages/vectordb_storages/qdrant.py +4 -4
- camel/tasks/__init__.py +4 -4
- camel/tasks/task.py +4 -4
- camel/tasks/task_prompt.py +4 -4
- camel/terminators/__init__.py +4 -4
- camel/terminators/base.py +4 -4
- camel/terminators/response_terminator.py +4 -4
- camel/terminators/token_limit_terminator.py +4 -4
- camel/toolkits/__init__.py +13 -17
- camel/toolkits/arxiv_toolkit.py +4 -4
- camel/toolkits/ask_news_toolkit.py +7 -18
- camel/toolkits/base.py +4 -4
- camel/toolkits/code_execution.py +20 -7
- camel/toolkits/dalle_toolkit.py +4 -7
- camel/toolkits/data_commons_toolkit.py +4 -4
- camel/toolkits/function_tool.py +220 -69
- camel/toolkits/github_toolkit.py +4 -4
- camel/toolkits/google_maps_toolkit.py +4 -4
- camel/toolkits/google_scholar_toolkit.py +4 -4
- camel/toolkits/human_toolkit.py +52 -0
- camel/toolkits/linkedin_toolkit.py +4 -4
- camel/toolkits/math_toolkit.py +4 -7
- camel/toolkits/notion_toolkit.py +4 -4
- camel/toolkits/open_api_specs/biztoc/__init__.py +4 -4
- camel/toolkits/open_api_specs/coursera/__init__.py +4 -4
- camel/toolkits/open_api_specs/create_qr_code/__init__.py +4 -4
- camel/toolkits/open_api_specs/klarna/__init__.py +4 -4
- camel/toolkits/open_api_specs/nasa_apod/__init__.py +4 -4
- camel/toolkits/open_api_specs/outschool/__init__.py +4 -4
- camel/toolkits/open_api_specs/outschool/paths/__init__.py +4 -4
- camel/toolkits/open_api_specs/outschool/paths/get_classes.py +4 -4
- camel/toolkits/open_api_specs/outschool/paths/search_teachers.py +4 -4
- camel/toolkits/open_api_specs/security_config.py +4 -4
- camel/toolkits/open_api_specs/speak/__init__.py +4 -4
- camel/toolkits/open_api_specs/web_scraper/__init__.py +4 -4
- camel/toolkits/open_api_specs/web_scraper/paths/__init__.py +4 -4
- camel/toolkits/open_api_specs/web_scraper/paths/scraper.py +4 -4
- camel/toolkits/open_api_toolkit.py +4 -4
- camel/toolkits/reddit_toolkit.py +4 -4
- camel/toolkits/retrieval_toolkit.py +4 -4
- camel/toolkits/search_toolkit.py +49 -29
- camel/toolkits/slack_toolkit.py +4 -4
- camel/toolkits/twitter_toolkit.py +10 -13
- camel/toolkits/video_toolkit.py +211 -0
- camel/toolkits/weather_toolkit.py +4 -7
- camel/toolkits/whatsapp_toolkit.py +6 -6
- camel/types/__init__.py +6 -4
- camel/types/enums.py +77 -7
- camel/types/openai_types.py +6 -4
- camel/types/unified_model_type.py +9 -4
- camel/utils/__init__.py +35 -33
- camel/utils/async_func.py +4 -4
- camel/utils/commons.py +4 -4
- camel/utils/constants.py +4 -4
- camel/utils/response_format.py +63 -0
- camel/utils/token_counting.py +4 -4
- {camel_ai-0.2.9.dist-info → camel_ai-0.2.10.dist-info}/METADATA +108 -56
- camel_ai-0.2.10.dist-info/RECORD +246 -0
- camel_ai-0.2.9.dist-info/RECORD +0 -215
- {camel_ai-0.2.9.dist-info → camel_ai-0.2.10.dist-info}/LICENSE +0 -0
- {camel_ai-0.2.9.dist-info → camel_ai-0.2.10.dist-info}/WHEEL +0 -0
camel/configs/base_config.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
# you may not use this file except in compliance with the License.
|
|
4
4
|
# You may obtain a copy of the License at
|
|
5
5
|
#
|
|
6
6
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
7
|
#
|
|
8
8
|
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
10
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
|
-
#
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
16
|
from abc import ABC
|
|
@@ -0,0 +1,76 @@
|
|
|
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 __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import List, Optional
|
|
17
|
+
|
|
18
|
+
from camel.configs.base_config import BaseConfig
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class CohereConfig(BaseConfig):
|
|
22
|
+
r"""Defines the parameters for generating chat completions using the
|
|
23
|
+
Cohere API.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
temperature (float, optional): Sampling temperature to use, between
|
|
27
|
+
:obj:`0` and :obj:`2`. Higher values make the output more random,
|
|
28
|
+
while lower values make it more focused and deterministic.
|
|
29
|
+
(default: :obj:`0.3`)
|
|
30
|
+
documents (list, optional): A list of relevant documents that the
|
|
31
|
+
model can cite to generate a more accurate reply. Each document is
|
|
32
|
+
either a string or document object with content and metadata.
|
|
33
|
+
(default: :obj:`None`)
|
|
34
|
+
max_tokens (int, optional): The maximum number of tokens the model
|
|
35
|
+
will generate as part of the response. (default: :obj:`None`)
|
|
36
|
+
stop_sequences (List(str), optional): A list of up to 5 strings that
|
|
37
|
+
the model will use to stop generation. If the model generates a
|
|
38
|
+
string that matches any of the strings in the list, it will stop
|
|
39
|
+
generating tokens and return the generated text up to that point
|
|
40
|
+
not including the stop sequence. (default: :obj:`None`)
|
|
41
|
+
seed (int, optional): If specified, the backend will make a best
|
|
42
|
+
effort to sample tokens deterministically, such that repeated
|
|
43
|
+
requests with the same seed and parameters should return the same
|
|
44
|
+
result. However, determinism cannot be totally guaranteed.
|
|
45
|
+
(default: :obj:`None`)
|
|
46
|
+
frequency_penalty (float, optional): Min value of `0.0`, max value of
|
|
47
|
+
`1.0`. Used to reduce repetitiveness of generated tokens. The
|
|
48
|
+
higher the value, the stronger a penalty is applied to previously
|
|
49
|
+
present tokens, proportional to how many times they have already
|
|
50
|
+
appeared in the prompt or prior generation. (default: :obj:`0.0`)
|
|
51
|
+
presence_penalty (float, optional): Min value of `0.0`, max value of
|
|
52
|
+
`1.0`. Used to reduce repetitiveness of generated tokens. Similar
|
|
53
|
+
to `frequency_penalty`, except that this penalty is applied
|
|
54
|
+
equally to all tokens that have already appeared, regardless of
|
|
55
|
+
their exact frequencies. (default: :obj:`0.0`)
|
|
56
|
+
k (int, optional): Ensures only the top k most likely tokens are
|
|
57
|
+
considered for generation at each step. Min value of `0`, max
|
|
58
|
+
value of `500`. (default: :obj:`0`)
|
|
59
|
+
p (float, optional): Ensures that only the most likely tokens, with
|
|
60
|
+
total probability mass of `p`, are considered for generation at
|
|
61
|
+
each step. If both k and p are enabled, `p` acts after `k`. Min
|
|
62
|
+
value of `0.01`, max value of `0.99`. (default: :obj:`0.75`)
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
temperature: Optional[float] = 0.2
|
|
66
|
+
documents: Optional[list] = None
|
|
67
|
+
max_tokens: Optional[int] = None
|
|
68
|
+
stop_sequences: Optional[List[str]] = None
|
|
69
|
+
seed: Optional[int] = None
|
|
70
|
+
frequency_penalty: Optional[float] = 0.0
|
|
71
|
+
presence_penalty: Optional[float] = 0.0
|
|
72
|
+
k: Optional[int] = 0
|
|
73
|
+
p: Optional[float] = 0.75
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
COHERE_API_PARAMS = {param for param in CohereConfig().model_fields.keys()}
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from typing import Any, Optional, Sequence, Type, Union
|
|
18
|
+
|
|
19
|
+
from pydantic import BaseModel
|
|
20
|
+
|
|
21
|
+
from camel.configs.base_config import BaseConfig
|
|
22
|
+
from camel.types import NOT_GIVEN, NotGiven
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class DeepSeekConfig(BaseConfig):
|
|
26
|
+
r"""Defines the parameters for generating chat completions using the
|
|
27
|
+
DeepSeek API.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
temperature (float, optional): Sampling temperature to use, between
|
|
31
|
+
:obj:`0` and :obj:`2`. Higher values make the output more random,
|
|
32
|
+
while lower values make it more focused and deterministic.
|
|
33
|
+
(default: :obj:`0.2`)
|
|
34
|
+
top_p (float, optional): Controls the diversity and focus of the
|
|
35
|
+
generated results. Higher values make the output more diverse,
|
|
36
|
+
while lower values make it more focused. (default: :obj:`1.0`)
|
|
37
|
+
response_format (object, optional): Specifies the format of the
|
|
38
|
+
returned content. The available values are `{"type": "text"}` or
|
|
39
|
+
`{"type": "json_object"}`. Setting it to `{"type": "json_object"}`
|
|
40
|
+
will output a standard JSON string.
|
|
41
|
+
(default: :obj:`{"type": "text"}`)
|
|
42
|
+
stream (bool, optional): If set, partial message deltas will be sent.
|
|
43
|
+
Tokens will be sent as data-only server-sent events (SSE) as
|
|
44
|
+
they become available, with the stream terminated by a
|
|
45
|
+
data: [DONE] message. (default: :obj:`False`)
|
|
46
|
+
stop (Union[str, list[str]], optional): Up to 16 sequences where
|
|
47
|
+
the API will stop generating further tokens. (default: :obj:`None`)
|
|
48
|
+
max_tokens (int, optional): The maximum number of tokens that can
|
|
49
|
+
be generated in the chat completion. The total length of input
|
|
50
|
+
tokens and generated tokens is limited by the model's context
|
|
51
|
+
length. (default: :obj:`None`)
|
|
52
|
+
presence_penalty (float, optional): Number between -2.0 and 2.0.
|
|
53
|
+
Positive values penalize new tokens based on whether they
|
|
54
|
+
appear in the text so far, increasing the model's likelihood
|
|
55
|
+
to talk about new topics. (default: :obj:`0.0`)
|
|
56
|
+
frequency_penalty (float, optional): Number between -2.0 and 2.0.
|
|
57
|
+
Positive values penalize new tokens based on their existing
|
|
58
|
+
frequency in the text so far, decreasing the model's likelihood
|
|
59
|
+
to repeat the same line verbatim. (default: :obj:`0`)
|
|
60
|
+
tools (list[FunctionTool], optional): A list of tools the model may
|
|
61
|
+
call. Currently, only functions are supported as a tool. Use
|
|
62
|
+
this to provide a list of functions the model may generate JSON
|
|
63
|
+
inputs for. A max of 128 functions are supported.
|
|
64
|
+
(default: :obj:`None`)
|
|
65
|
+
tool_choice (Union[dict[str, str], str], optional): Controls which
|
|
66
|
+
(if any) tool is called by the model. "none" means the model
|
|
67
|
+
will not call any tool and instead generates a message. "auto"
|
|
68
|
+
means the model can pick between generating a message or calling
|
|
69
|
+
one or more tools. "required" means the model must call one or
|
|
70
|
+
more tools. Specifying a particular tool via
|
|
71
|
+
{"type": "function", "function": {"name": "my_function"}} forces
|
|
72
|
+
the model to call that tool. "none" is the default when no tools
|
|
73
|
+
are present. "auto" is the default if tools are present.
|
|
74
|
+
(default: :obj:`"auto"`)
|
|
75
|
+
logprobs (bool, optional): Whether to return log probabilities of
|
|
76
|
+
the output tokens or not. If true, returns the log probabilities
|
|
77
|
+
of each output token returned in the content of message.
|
|
78
|
+
(default: :obj:`False`)
|
|
79
|
+
top_logprobs (int, optional): An integer between 0 and 20 specifying
|
|
80
|
+
the number of most likely tokens to return at each token
|
|
81
|
+
position, each with an associated log probability. logprobs
|
|
82
|
+
must be set to true if this parameter is used.
|
|
83
|
+
(default: :obj:`None`)
|
|
84
|
+
include_usage (bool, optional): When streaming, specifies whether to
|
|
85
|
+
include usage information in `stream_options`. (default:
|
|
86
|
+
:obj:`True`)
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
temperature: float = 0.2 # deepseek default: 1.0
|
|
90
|
+
top_p: float = 1.0
|
|
91
|
+
stream: bool = False
|
|
92
|
+
stop: Union[str, Sequence[str], NotGiven] = NOT_GIVEN
|
|
93
|
+
max_tokens: Union[int, NotGiven] = NOT_GIVEN
|
|
94
|
+
presence_penalty: float = 0.0
|
|
95
|
+
response_format: Union[Type[BaseModel], dict, NotGiven] = NOT_GIVEN
|
|
96
|
+
frequency_penalty: float = 0.0
|
|
97
|
+
tool_choice: Optional[Union[dict[str, str], str]] = None
|
|
98
|
+
logprobs: bool = False
|
|
99
|
+
top_logprobs: Optional[int] = None
|
|
100
|
+
|
|
101
|
+
def __init__(self, include_usage: bool = True, **kwargs):
|
|
102
|
+
super().__init__(**kwargs)
|
|
103
|
+
# Only set stream_options when stream is True
|
|
104
|
+
# Otherwise, it will raise error when calling the API
|
|
105
|
+
if self.stream:
|
|
106
|
+
self.stream_options = {"include_usage": include_usage}
|
|
107
|
+
|
|
108
|
+
def as_dict(self) -> dict[str, Any]:
|
|
109
|
+
r"""Convert the current configuration to a dictionary.
|
|
110
|
+
|
|
111
|
+
This method converts the current configuration object to a dictionary
|
|
112
|
+
representation, which can be used for serialization or other purposes.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
dict[str, Any]: A dictionary representation of the current
|
|
116
|
+
configuration.
|
|
117
|
+
"""
|
|
118
|
+
config_dict = self.model_dump()
|
|
119
|
+
if self.tools:
|
|
120
|
+
from camel.toolkits import FunctionTool
|
|
121
|
+
|
|
122
|
+
tools_schema = []
|
|
123
|
+
for tool in self.tools:
|
|
124
|
+
if not isinstance(tool, FunctionTool):
|
|
125
|
+
raise ValueError(
|
|
126
|
+
f"The tool {tool} should "
|
|
127
|
+
"be an instance of `FunctionTool`."
|
|
128
|
+
)
|
|
129
|
+
tools_schema.append(tool.get_openai_tool_schema())
|
|
130
|
+
config_dict["tools"] = NOT_GIVEN
|
|
131
|
+
return config_dict
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
DEEPSEEK_API_PARAMS = {param for param in DeepSeekConfig.model_fields.keys()}
|
camel/configs/gemini_config.py
CHANGED
|
@@ -1,156 +1,114 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
# you may not use this file except in compliance with the License.
|
|
4
4
|
# You may obtain a copy of the License at
|
|
5
5
|
#
|
|
6
6
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
7
|
#
|
|
8
8
|
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
10
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
|
-
#
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
|
|
15
|
+
from __future__ import annotations
|
|
15
16
|
|
|
16
|
-
from
|
|
17
|
-
from typing import Any, Optional
|
|
17
|
+
from typing import Any, Optional, Sequence, Type, Union
|
|
18
18
|
|
|
19
|
-
from pydantic import
|
|
19
|
+
from pydantic import BaseModel
|
|
20
20
|
|
|
21
21
|
from camel.configs.base_config import BaseConfig
|
|
22
|
+
from camel.types import NOT_GIVEN, NotGiven
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
class GeminiConfig(BaseConfig):
|
|
25
|
-
r"""
|
|
26
|
-
|
|
26
|
+
r"""Defines the parameters for generating chat completions using the
|
|
27
|
+
Gemini API.
|
|
27
28
|
|
|
28
29
|
Args:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
generated
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
more
|
|
71
|
-
|
|
72
|
-
|
|
30
|
+
temperature (float, optional): Sampling temperature to use, between
|
|
31
|
+
:obj:`0` and :obj:`2`. Higher values make the output more random,
|
|
32
|
+
while lower values make it more focused and deterministic.
|
|
33
|
+
(default: :obj:`0.2`)
|
|
34
|
+
top_p (float, optional): An alternative to sampling with temperature,
|
|
35
|
+
called nucleus sampling, where the model considers the results of
|
|
36
|
+
the tokens with top_p probability mass. So :obj:`0.1` means only
|
|
37
|
+
the tokens comprising the top 10% probability mass are considered.
|
|
38
|
+
(default: :obj:`1.0`)
|
|
39
|
+
n (int, optional): How many chat completion choices to generate for
|
|
40
|
+
each input message. (default: :obj:`1`)
|
|
41
|
+
response_format (object, optional): An object specifying the format
|
|
42
|
+
that the model must output. Compatible with GPT-4 Turbo and all
|
|
43
|
+
GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106. Setting to
|
|
44
|
+
{"type": "json_object"} enables JSON mode, which guarantees the
|
|
45
|
+
message the model generates is valid JSON. Important: when using
|
|
46
|
+
JSON mode, you must also instruct the model to produce JSON
|
|
47
|
+
yourself via a system or user message. Without this, the model
|
|
48
|
+
may generate an unending stream of whitespace until the generation
|
|
49
|
+
reaches the token limit, resulting in a long-running and seemingly
|
|
50
|
+
"stuck" request. Also note that the message content may be
|
|
51
|
+
partially cut off if finish_reason="length", which indicates the
|
|
52
|
+
generation exceeded max_tokens or the conversation exceeded the
|
|
53
|
+
max context length.
|
|
54
|
+
stream (bool, optional): If True, partial message deltas will be sent
|
|
55
|
+
as data-only server-sent events as they become available.
|
|
56
|
+
(default: :obj:`False`)
|
|
57
|
+
stop (str or list, optional): Up to :obj:`4` sequences where the API
|
|
58
|
+
will stop generating further tokens. (default: :obj:`None`)
|
|
59
|
+
max_tokens (int, optional): The maximum number of tokens to generate
|
|
60
|
+
in the chat completion. The total length of input tokens and
|
|
61
|
+
generated tokens is limited by the model's context length.
|
|
62
|
+
(default: :obj:`None`)
|
|
63
|
+
tools (list[FunctionTool], optional): A list of tools the model may
|
|
64
|
+
call. Currently, only functions are supported as a tool. Use this
|
|
65
|
+
to provide a list of functions the model may generate JSON inputs
|
|
66
|
+
for. A max of 128 functions are supported.
|
|
67
|
+
tool_choice (Union[dict[str, str], str], optional): Controls which (if
|
|
68
|
+
any) tool is called by the model. :obj:`"none"` means the model
|
|
69
|
+
will not call any tool and instead generates a message.
|
|
70
|
+
:obj:`"auto"` means the model can pick between generating a
|
|
71
|
+
message or calling one or more tools. :obj:`"required"` means the
|
|
72
|
+
model must call one or more tools. Specifying a particular tool
|
|
73
|
+
via {"type": "function", "function": {"name": "my_function"}}
|
|
74
|
+
forces the model to call that tool. :obj:`"none"` is the default
|
|
75
|
+
when no tools are present. :obj:`"auto"` is the default if tools
|
|
76
|
+
are present.
|
|
73
77
|
"""
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
safety_settings: Optional[Any] = None
|
|
84
|
-
tool_config: Optional[Any] = None
|
|
85
|
-
request_options: Optional[Any] = None
|
|
79
|
+
temperature: float = 0.2 # openai default: 1.0
|
|
80
|
+
top_p: float = 1.0
|
|
81
|
+
n: int = 1
|
|
82
|
+
stream: bool = False
|
|
83
|
+
stop: Union[str, Sequence[str], NotGiven] = NOT_GIVEN
|
|
84
|
+
max_tokens: Union[int, NotGiven] = NOT_GIVEN
|
|
85
|
+
response_format: Union[Type[BaseModel], dict, NotGiven] = NOT_GIVEN
|
|
86
|
+
tool_choice: Optional[Union[dict[str, str], str]] = None
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def model_type_checking(cls, data: Any):
|
|
90
|
-
r"""Validate the type of tools in the configuration.
|
|
88
|
+
def as_dict(self) -> dict[str, Any]:
|
|
89
|
+
r"""Convert the current configuration to a dictionary.
|
|
91
90
|
|
|
92
|
-
This method
|
|
93
|
-
|
|
94
|
-
`FunctionTool`, it raises a ValueError.
|
|
95
|
-
"""
|
|
96
|
-
if isinstance(data, dict):
|
|
97
|
-
response_schema = data.get("response_schema")
|
|
98
|
-
safety_settings = data.get("safety_settings")
|
|
99
|
-
tools = data.get("tools")
|
|
100
|
-
tool_config = data.get("tool_config")
|
|
101
|
-
request_options = data.get("request_options")
|
|
102
|
-
|
|
103
|
-
if response_schema:
|
|
104
|
-
from google.generativeai.protos import Schema
|
|
105
|
-
from google.generativeai.types.content_types import (
|
|
106
|
-
FunctionLibraryType,
|
|
107
|
-
ToolConfigType,
|
|
108
|
-
)
|
|
109
|
-
from google.generativeai.types.helper_types import (
|
|
110
|
-
RequestOptionsType,
|
|
111
|
-
)
|
|
112
|
-
from google.generativeai.types.safety_types import (
|
|
113
|
-
SafetySettingOptions,
|
|
114
|
-
)
|
|
115
|
-
else:
|
|
116
|
-
return data
|
|
91
|
+
This method converts the current configuration object to a dictionary
|
|
92
|
+
representation, which can be used for serialization or other purposes.
|
|
117
93
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
safety_settings, SafetySettingOptions
|
|
126
|
-
):
|
|
127
|
-
raise ValueError(
|
|
128
|
-
"The safety_settings should be an instance of "
|
|
129
|
-
"google.generativeai.types.safety_types."
|
|
130
|
-
"SafetySettingOptions."
|
|
131
|
-
)
|
|
94
|
+
Returns:
|
|
95
|
+
dict[str, Any]: A dictionary representation of the current
|
|
96
|
+
configuration.
|
|
97
|
+
"""
|
|
98
|
+
config_dict = self.model_dump()
|
|
99
|
+
if self.tools:
|
|
100
|
+
from camel.toolkits import FunctionTool
|
|
132
101
|
|
|
133
|
-
|
|
134
|
-
for tool in tools:
|
|
135
|
-
if not isinstance(tool,
|
|
102
|
+
tools_schema = []
|
|
103
|
+
for tool in self.tools:
|
|
104
|
+
if not isinstance(tool, FunctionTool):
|
|
136
105
|
raise ValueError(
|
|
137
|
-
"The tool should
|
|
138
|
-
"
|
|
139
|
-
"FunctionLibraryType."
|
|
106
|
+
f"The tool {tool} should "
|
|
107
|
+
"be an instance of `FunctionTool`."
|
|
140
108
|
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"google.generativeai.types.content_types.ToolConfigType."
|
|
145
|
-
)
|
|
146
|
-
if request_options and not isinstance(
|
|
147
|
-
request_options, RequestOptionsType
|
|
148
|
-
):
|
|
149
|
-
raise ValueError(
|
|
150
|
-
"The request_options should be an instance of "
|
|
151
|
-
"google.generativeai.types.helper_types.RequestOptionsType."
|
|
152
|
-
)
|
|
153
|
-
return data
|
|
109
|
+
tools_schema.append(tool.get_openai_tool_schema())
|
|
110
|
+
config_dict["tools"] = NOT_GIVEN
|
|
111
|
+
return config_dict
|
|
154
112
|
|
|
155
113
|
|
|
156
|
-
Gemini_API_PARAMS = {param for param in GeminiConfig
|
|
114
|
+
Gemini_API_PARAMS = {param for param in GeminiConfig.model_fields.keys()}
|
camel/configs/groq_config.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
# you may not use this file except in compliance with the License.
|
|
4
4
|
# You may obtain a copy of the License at
|
|
5
5
|
#
|
|
6
6
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
7
|
#
|
|
8
8
|
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
10
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
|
-
#
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
16
|
from typing import Optional, Sequence, Union
|
camel/configs/litellm_config.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
# you may not use this file except in compliance with the License.
|
|
4
4
|
# You may obtain a copy of the License at
|
|
5
5
|
#
|
|
6
6
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
7
|
#
|
|
8
8
|
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
10
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
|
-
#
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
16
|
from typing import List, Optional, Union
|
camel/configs/mistral_config.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
# you may not use this file except in compliance with the License.
|
|
4
4
|
# You may obtain a copy of the License at
|
|
5
5
|
#
|
|
6
6
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
7
|
#
|
|
8
8
|
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
10
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
|
-
#
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
16
|
from typing import Any, Dict, Optional, Union
|
camel/configs/ollama_config.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
# you may not use this file except in compliance with the License.
|
|
4
4
|
# You may obtain a copy of the License at
|
|
5
5
|
#
|
|
6
6
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
7
|
#
|
|
8
8
|
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
10
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
|
-
#
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
16
|
from typing import Sequence, Union
|
camel/configs/openai_config.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
# you may not use this file except in compliance with the License.
|
|
4
4
|
# You may obtain a copy of the License at
|
|
5
5
|
#
|
|
6
6
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
7
|
#
|
|
8
8
|
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
10
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
|
-
#
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
|
-
from typing import Optional, Sequence, Union
|
|
16
|
+
from typing import Any, Optional, Sequence, Type, Union
|
|
17
17
|
|
|
18
|
-
from pydantic import Field
|
|
18
|
+
from pydantic import BaseModel, Field
|
|
19
19
|
|
|
20
20
|
from camel.configs.base_config import BaseConfig
|
|
21
21
|
from camel.types import NOT_GIVEN, NotGiven
|
|
@@ -104,11 +104,36 @@ class ChatGPTConfig(BaseConfig):
|
|
|
104
104
|
stop: Union[str, Sequence[str], NotGiven] = NOT_GIVEN
|
|
105
105
|
max_tokens: Union[int, NotGiven] = NOT_GIVEN
|
|
106
106
|
presence_penalty: float = 0.0
|
|
107
|
-
response_format: Union[dict, NotGiven] = NOT_GIVEN
|
|
107
|
+
response_format: Union[Type[BaseModel], dict, NotGiven] = NOT_GIVEN
|
|
108
108
|
frequency_penalty: float = 0.0
|
|
109
109
|
logit_bias: dict = Field(default_factory=dict)
|
|
110
110
|
user: str = ""
|
|
111
111
|
tool_choice: Optional[Union[dict[str, str], str]] = None
|
|
112
112
|
|
|
113
|
+
def as_dict(self) -> dict[str, Any]:
|
|
114
|
+
r"""Convert the current configuration to a dictionary.
|
|
115
|
+
|
|
116
|
+
This method converts the current configuration object to a dictionary
|
|
117
|
+
representation, which can be used for serialization or other purposes.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
dict[str, Any]: A dictionary representation of the current
|
|
121
|
+
configuration.
|
|
122
|
+
"""
|
|
123
|
+
config_dict = self.model_dump()
|
|
124
|
+
if self.tools:
|
|
125
|
+
from camel.toolkits import FunctionTool
|
|
126
|
+
|
|
127
|
+
tools_schema = []
|
|
128
|
+
for tool in self.tools:
|
|
129
|
+
if not isinstance(tool, FunctionTool):
|
|
130
|
+
raise ValueError(
|
|
131
|
+
f"The tool {tool} should "
|
|
132
|
+
"be an instance of `FunctionTool`."
|
|
133
|
+
)
|
|
134
|
+
tools_schema.append(tool.get_openai_tool_schema())
|
|
135
|
+
config_dict["tools"] = NOT_GIVEN
|
|
136
|
+
return config_dict
|
|
137
|
+
|
|
113
138
|
|
|
114
139
|
OPENAI_API_PARAMS = {param for param in ChatGPTConfig.model_fields.keys()}
|