camel-ai 0.2.9__py3-none-any.whl → 0.2.11__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 +10 -5
- camel/agents/__init__.py +4 -4
- camel/agents/base.py +4 -4
- camel/agents/chat_agent.py +106 -42
- camel/agents/critic_agent.py +4 -4
- camel/agents/deductive_reasoner_agent.py +8 -5
- 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 +13 -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 -7
- camel/configs/nvidia_config.py +70 -0
- 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 +14 -5
- 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 +8 -5
- 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 +11 -6
- 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 +11 -6
- 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 -7
- camel/loaders/jina_url_reader.py +4 -4
- camel/loaders/unstructured_io.py +4 -4
- camel/logger.py +112 -0
- 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 +118 -11
- camel/messages/conversion/__init__.py +31 -0
- camel/messages/conversion/alpaca.py +122 -0
- camel/messages/conversion/conversation_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 +13 -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 +13 -4
- camel/models/model_manager.py +212 -0
- camel/models/nemotron_model.py +4 -4
- camel/models/nvidia_model.py +141 -0
- 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 +43 -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 +26 -9
- 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 +8 -5
- 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 +16 -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 +57 -10
- 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 +53 -0
- camel/toolkits/linkedin_toolkit.py +4 -4
- camel/toolkits/math_toolkit.py +4 -7
- camel/toolkits/meshy_toolkit.py +185 -0
- 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 +13 -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 +118 -15
- 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 +26 -9
- camel/utils/constants.py +4 -4
- camel/utils/response_format.py +63 -0
- camel/utils/token_counting.py +8 -5
- {camel_ai-0.2.9.dist-info → camel_ai-0.2.11.dist-info}/METADATA +108 -56
- camel_ai-0.2.11.dist-info/RECORD +252 -0
- camel_ai-0.2.9.dist-info/RECORD +0 -215
- {camel_ai-0.2.9.dist-info → camel_ai-0.2.11.dist-info}/LICENSE +0 -0
- {camel_ai-0.2.9.dist-info → camel_ai-0.2.11.dist-info}/WHEEL +0 -0
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
|
|
@@ -35,8 +35,6 @@ class MistralConfig(BaseConfig):
|
|
|
35
35
|
tokens to generate, e.g. 0.9. Defaults to None.
|
|
36
36
|
max_tokens (Optional[int], optional): the maximum number of tokens to
|
|
37
37
|
generate, e.g. 100. Defaults to None.
|
|
38
|
-
min_tokens (Optional[int], optional): the minimum number of tokens to
|
|
39
|
-
generate, e.g. 100. Defaults to None.
|
|
40
38
|
stop (Optional[Union[str,list[str]]]): Stop generation if this token
|
|
41
39
|
is detected. Or if one of these tokens is detected when providing
|
|
42
40
|
a string list.
|
|
@@ -58,7 +56,6 @@ class MistralConfig(BaseConfig):
|
|
|
58
56
|
temperature: Optional[float] = None
|
|
59
57
|
top_p: Optional[float] = None
|
|
60
58
|
max_tokens: Optional[int] = None
|
|
61
|
-
min_tokens: Optional[int] = None
|
|
62
59
|
stop: Optional[Union[str, list[str]]] = None
|
|
63
60
|
random_seed: Optional[int] = None
|
|
64
61
|
safe_prompt: bool = False
|
|
@@ -0,0 +1,70 @@
|
|
|
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, Union
|
|
17
|
+
|
|
18
|
+
from pydantic import Field
|
|
19
|
+
|
|
20
|
+
from camel.configs.base_config import BaseConfig
|
|
21
|
+
from camel.types import NOT_GIVEN, NotGiven
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class NvidiaConfig(BaseConfig):
|
|
25
|
+
r"""Configuration class for NVIDIA API models.
|
|
26
|
+
|
|
27
|
+
This class defines the configuration parameters for NVIDIA's language
|
|
28
|
+
models, including temperature, sampling parameters, and response format
|
|
29
|
+
settings.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
stream (bool, optional): Whether to stream the response.
|
|
33
|
+
(default: :obj:`False`)
|
|
34
|
+
temperature (float, optional): Controls randomness in the response.
|
|
35
|
+
Higher values make output more random, lower values make it more
|
|
36
|
+
deterministic. Range: [0.0, 2.0]. (default: :obj:`0.7`)
|
|
37
|
+
top_p (float, optional): Controls diversity via nucleus sampling.
|
|
38
|
+
Range: [0.0, 1.0]. (default: :obj:`0.95`)
|
|
39
|
+
presence_penalty (float, optional): Penalizes new tokens based on
|
|
40
|
+
whether they appear in the text so far. Range: [-2.0, 2.0].
|
|
41
|
+
(default: :obj:`0.0`)
|
|
42
|
+
frequency_penalty (float, optional): Penalizes new tokens based on
|
|
43
|
+
their frequency in the text so far. Range: [-2.0, 2.0].
|
|
44
|
+
(default: :obj:`0.0`)
|
|
45
|
+
max_tokens (Union[int, NotGiven], optional): Maximum number of tokens
|
|
46
|
+
to generate. If not provided, model will use its default maximum.
|
|
47
|
+
(default: :obj:`NOT_GIVEN`)
|
|
48
|
+
seed (Optional[int], optional): Random seed for deterministic sampling.
|
|
49
|
+
(default: :obj:`None`)
|
|
50
|
+
tools (Optional[List[Dict]], optional): List of tools available to the
|
|
51
|
+
model. This includes tools such as a text editor, a calculator, or
|
|
52
|
+
a search engine. (default: :obj:`None`)
|
|
53
|
+
tool_choice (Optional[str], optional): Tool choice configuration.
|
|
54
|
+
(default: :obj:`None`)
|
|
55
|
+
stop (Optional[List[str]], optional): List of stop sequences.
|
|
56
|
+
(default: :obj:`None`)
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
stream: bool = Field(default=False)
|
|
60
|
+
temperature: float = Field(default=0.7)
|
|
61
|
+
top_p: float = Field(default=0.95)
|
|
62
|
+
presence_penalty: float = Field(default=0.0)
|
|
63
|
+
frequency_penalty: float = Field(default=0.0)
|
|
64
|
+
max_tokens: Union[int, NotGiven] = Field(default=NOT_GIVEN)
|
|
65
|
+
seed: Optional[int] = Field(default=None)
|
|
66
|
+
tool_choice: Optional[str] = Field(default=None)
|
|
67
|
+
stop: Optional[List[str]] = Field(default=None)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
NVIDIA_API_PARAMS = {param for param in NvidiaConfig.model_fields.keys()}
|
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()}
|
camel/configs/qwen_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 ClassVar, Optional, Union
|
camel/configs/reka_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, Optional, Union
|
camel/configs/samba_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, Optional, Sequence, Union
|
|
@@ -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, Sequence, Union
|
camel/configs/vllm_config.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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 Sequence, Union
|
|
16
|
+
from typing import Optional, Sequence, Union
|
|
17
17
|
|
|
18
18
|
from pydantic import Field
|
|
19
19
|
|
|
@@ -84,6 +84,13 @@ class VLLMConfig(BaseConfig):
|
|
|
84
84
|
user (str, optional): A unique identifier representing your end-user,
|
|
85
85
|
which can help OpenAI to monitor and detect abuse.
|
|
86
86
|
(default: :obj:`""`)
|
|
87
|
+
logprobs: Whether to return log probabilities of the output tokens or
|
|
88
|
+
not. If true, returns the log probabilities of each output token
|
|
89
|
+
returned in the `logits` of `message`. (default: :obj:`None`)
|
|
90
|
+
top_logprobs: An integer between 0 and 20 specifying the number of
|
|
91
|
+
most likely tokens to return at each token position, each with an
|
|
92
|
+
associated log probability. `logprobs` must be set to `true` if
|
|
93
|
+
this parameter is used. (default: :obj:`None`)
|
|
87
94
|
"""
|
|
88
95
|
|
|
89
96
|
temperature: float = 0.2 # openai default: 1.0
|
|
@@ -97,6 +104,8 @@ class VLLMConfig(BaseConfig):
|
|
|
97
104
|
frequency_penalty: float = 0.0
|
|
98
105
|
logit_bias: dict = Field(default_factory=dict)
|
|
99
106
|
user: str = ""
|
|
107
|
+
logprobs: Optional[bool] = None
|
|
108
|
+
top_logprobs: Optional[int] = None
|
|
100
109
|
|
|
101
110
|
|
|
102
111
|
VLLM_API_PARAMS = {param for param in VLLMConfig.model_fields.keys()}
|