camel-ai 0.1.9__py3-none-any.whl → 0.2.3__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 +334 -113
- camel/agents/knowledge_graph_agent.py +4 -6
- camel/bots/__init__.py +34 -0
- 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/bots/telegram_bot.py +82 -0
- camel/configs/__init__.py +1 -2
- camel/configs/anthropic_config.py +2 -5
- camel/configs/base_config.py +6 -6
- camel/configs/gemini_config.py +1 -1
- 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 +13 -45
- camel/loaders/unstructured_io.py +65 -29
- camel/messages/__init__.py +1 -0
- camel/messages/func_message.py +2 -2
- 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 +33 -30
- 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} +36 -41
- camel/models/openai_model.py +60 -25
- 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 +28 -10
- camel/retrievers/vector_retriever.py +72 -44
- camel/societies/babyagi_playing.py +6 -3
- camel/societies/role_playing.py +17 -3
- camel/storages/__init__.py +2 -0
- camel/storages/graph_storages/__init__.py +2 -0
- camel/storages/graph_storages/graph_element.py +3 -5
- camel/storages/graph_storages/nebula_graph.py +547 -0
- camel/storages/key_value_storages/json.py +6 -1
- camel/tasks/task.py +11 -4
- camel/tasks/task_prompt.py +4 -0
- camel/toolkits/__init__.py +28 -24
- 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 -14
- camel/toolkits/google_scholar_toolkit.py +146 -0
- camel/toolkits/linkedin_toolkit.py +7 -10
- camel/toolkits/math_toolkit.py +8 -8
- camel/toolkits/open_api_toolkit.py +5 -8
- camel/toolkits/reddit_toolkit.py +7 -10
- camel/toolkits/retrieval_toolkit.py +5 -9
- camel/toolkits/search_toolkit.py +9 -9
- camel/toolkits/slack_toolkit.py +11 -14
- camel/toolkits/twitter_toolkit.py +377 -454
- camel/toolkits/weather_toolkit.py +6 -6
- camel/toolkits/whatsapp_toolkit.py +177 -0
- camel/types/__init__.py +6 -1
- camel/types/enums.py +43 -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 +40 -4
- camel/utils/token_counting.py +38 -214
- camel/workforce/__init__.py +6 -6
- camel/workforce/base.py +9 -5
- camel/workforce/prompts.py +179 -0
- camel/workforce/role_playing_worker.py +181 -0
- camel/workforce/{single_agent_node.py → single_agent_worker.py} +49 -23
- camel/workforce/task_channel.py +7 -8
- camel/workforce/utils.py +20 -50
- camel/workforce/{worker_node.py → worker.py} +15 -12
- camel/workforce/workforce.py +456 -19
- camel_ai-0.2.3.dist-info/LICENSE +201 -0
- {camel_ai-0.1.9.dist-info → camel_ai-0.2.3.dist-info}/METADATA +40 -65
- {camel_ai-0.1.9.dist-info → camel_ai-0.2.3.dist-info}/RECORD +98 -86
- {camel_ai-0.1.9.dist-info → camel_ai-0.2.3.dist-info}/WHEEL +1 -1
- camel/models/open_source_model.py +0 -170
- camel/workforce/manager_node.py +0 -299
- camel/workforce/role_playing_node.py +0 -168
- camel/workforce/workforce_prompt.py +0 -125
camel/toolkits/__init__.py
CHANGED
|
@@ -12,46 +12,41 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
|
|
14
14
|
# ruff: noqa: I001
|
|
15
|
-
from .
|
|
15
|
+
from .function_tool import (
|
|
16
|
+
FunctionTool,
|
|
16
17
|
OpenAIFunction,
|
|
17
18
|
get_openai_function_schema,
|
|
18
19
|
get_openai_tool_schema,
|
|
19
20
|
)
|
|
20
21
|
from .open_api_specs.security_config import openapi_security_config
|
|
21
22
|
|
|
22
|
-
from .google_maps_toolkit import MAP_FUNCS, GoogleMapsToolkit
|
|
23
|
-
from .math_toolkit import MATH_FUNCS, MathToolkit
|
|
24
|
-
from .open_api_toolkit import OPENAPI_FUNCS, OpenAPIToolkit
|
|
25
|
-
from .retrieval_toolkit import RETRIEVAL_FUNCS, RetrievalToolkit
|
|
26
|
-
from .search_toolkit import SEARCH_FUNCS, SearchToolkit
|
|
27
|
-
from .twitter_toolkit import TWITTER_FUNCS, TwitterToolkit
|
|
28
|
-
from .weather_toolkit import WEATHER_FUNCS, WeatherToolkit
|
|
29
|
-
from .slack_toolkit import SLACK_FUNCS, SlackToolkit
|
|
30
|
-
from .dalle_toolkit import DALLE_FUNCS, DalleToolkit
|
|
31
|
-
from .linkedin_toolkit import LINKEDIN_FUNCS, LinkedInToolkit
|
|
32
|
-
from .reddit_toolkit import REDDIT_FUNCS, RedditToolkit
|
|
33
23
|
|
|
24
|
+
from .math_toolkit import MathToolkit, MATH_FUNCS
|
|
25
|
+
from .search_toolkit import SearchToolkit, SEARCH_FUNCS
|
|
26
|
+
from .weather_toolkit import WeatherToolkit, WEATHER_FUNCS
|
|
27
|
+
from .dalle_toolkit import DalleToolkit, DALLE_FUNCS
|
|
28
|
+
from .ask_news_toolkit import AskNewsToolkit, AsyncAskNewsToolkit
|
|
29
|
+
|
|
30
|
+
from .linkedin_toolkit import LinkedInToolkit
|
|
31
|
+
from .reddit_toolkit import RedditToolkit
|
|
34
32
|
from .base import BaseToolkit
|
|
33
|
+
from .google_maps_toolkit import GoogleMapsToolkit
|
|
35
34
|
from .code_execution import CodeExecutionToolkit
|
|
36
35
|
from .github_toolkit import GithubToolkit
|
|
36
|
+
from .google_scholar_toolkit import GoogleScholarToolkit
|
|
37
|
+
from .arxiv_toolkit import ArxivToolkit
|
|
38
|
+
from .slack_toolkit import SlackToolkit
|
|
39
|
+
from .twitter_toolkit import TwitterToolkit, TWITTER_FUNCS
|
|
40
|
+
from .open_api_toolkit import OpenAPIToolkit
|
|
41
|
+
from .retrieval_toolkit import RetrievalToolkit
|
|
37
42
|
|
|
38
43
|
__all__ = [
|
|
44
|
+
'BaseToolkit',
|
|
45
|
+
'FunctionTool',
|
|
39
46
|
'OpenAIFunction',
|
|
40
47
|
'get_openai_function_schema',
|
|
41
48
|
'get_openai_tool_schema',
|
|
42
49
|
'openapi_security_config',
|
|
43
|
-
'MATH_FUNCS',
|
|
44
|
-
'MAP_FUNCS',
|
|
45
|
-
'OPENAPI_FUNCS',
|
|
46
|
-
'RETRIEVAL_FUNCS',
|
|
47
|
-
'SEARCH_FUNCS',
|
|
48
|
-
'TWITTER_FUNCS',
|
|
49
|
-
'WEATHER_FUNCS',
|
|
50
|
-
'SLACK_FUNCS',
|
|
51
|
-
'DALLE_FUNCS',
|
|
52
|
-
'LINKEDIN_FUNCS',
|
|
53
|
-
'REDDIT_FUNCS',
|
|
54
|
-
'BaseToolkit',
|
|
55
50
|
'GithubToolkit',
|
|
56
51
|
'MathToolkit',
|
|
57
52
|
'GoogleMapsToolkit',
|
|
@@ -65,4 +60,13 @@ __all__ = [
|
|
|
65
60
|
'LinkedInToolkit',
|
|
66
61
|
'RedditToolkit',
|
|
67
62
|
'CodeExecutionToolkit',
|
|
63
|
+
'AskNewsToolkit',
|
|
64
|
+
'AsyncAskNewsToolkit',
|
|
65
|
+
'GoogleScholarToolkit',
|
|
66
|
+
'ArxivToolkit',
|
|
67
|
+
'MATH_FUNCS',
|
|
68
|
+
'SEARCH_FUNCS',
|
|
69
|
+
'WEATHER_FUNCS',
|
|
70
|
+
'DALLE_FUNCS',
|
|
71
|
+
'TWITTER_FUNCS',
|
|
68
72
|
]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# =========== Copyright 2023 @ 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 @ CAMEL-AI.org. All Rights Reserved. ===========
|
|
14
|
+
|
|
15
|
+
from typing import Dict, Generator, List, Optional
|
|
16
|
+
|
|
17
|
+
from camel.toolkits.base import BaseToolkit
|
|
18
|
+
from camel.toolkits.function_tool import FunctionTool
|
|
19
|
+
from camel.utils import dependencies_required
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ArxivToolkit(BaseToolkit):
|
|
23
|
+
r"""A toolkit for interacting with the arXiv API to search and download
|
|
24
|
+
academic papers.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
@dependencies_required('arxiv')
|
|
28
|
+
def __init__(self) -> None:
|
|
29
|
+
r"""Initializes the ArxivToolkit and sets up the arXiv client."""
|
|
30
|
+
import arxiv
|
|
31
|
+
|
|
32
|
+
self.client = arxiv.Client()
|
|
33
|
+
|
|
34
|
+
def _get_search_results(
|
|
35
|
+
self,
|
|
36
|
+
query: str,
|
|
37
|
+
paper_ids: Optional[List[str]] = None,
|
|
38
|
+
max_results: Optional[int] = 5,
|
|
39
|
+
) -> Generator:
|
|
40
|
+
r"""Retrieves search results from the arXiv API based on the provided
|
|
41
|
+
query and optional paper IDs.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
query (str): The search query string used to search for papers on
|
|
45
|
+
arXiv.
|
|
46
|
+
paper_ids (List[str], optional): A list of specific arXiv paper
|
|
47
|
+
IDs to search for. (default::obj: `None`)
|
|
48
|
+
max_results (int, optional): The maximum number of search results
|
|
49
|
+
to retrieve. (default::obj: `5`)
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
Generator: A generator that yields results from the arXiv search
|
|
53
|
+
query, which includes metadata about each paper matching the
|
|
54
|
+
query.
|
|
55
|
+
"""
|
|
56
|
+
import arxiv
|
|
57
|
+
|
|
58
|
+
paper_ids = paper_ids or []
|
|
59
|
+
search_query = arxiv.Search(
|
|
60
|
+
query=query,
|
|
61
|
+
id_list=paper_ids,
|
|
62
|
+
max_results=max_results,
|
|
63
|
+
)
|
|
64
|
+
return self.client.results(search_query)
|
|
65
|
+
|
|
66
|
+
def search_papers(
|
|
67
|
+
self,
|
|
68
|
+
query: str,
|
|
69
|
+
paper_ids: Optional[List[str]] = None,
|
|
70
|
+
max_results: Optional[int] = 5,
|
|
71
|
+
) -> List[Dict[str, str]]:
|
|
72
|
+
r"""Searches for academic papers on arXiv using a query string and
|
|
73
|
+
optional paper IDs.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
query (str): The search query string.
|
|
77
|
+
paper_ids (List[str], optional): A list of specific arXiv paper
|
|
78
|
+
IDs to search for. (default::obj: `None`)
|
|
79
|
+
max_results (int, optional): The maximum number of search results
|
|
80
|
+
to return. (default::obj: `5`)
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
List[Dict[str, str]]: A list of dictionaries, each containing
|
|
84
|
+
information about a paper, including title, published date,
|
|
85
|
+
authors, entry ID, summary, and extracted text from the paper.
|
|
86
|
+
"""
|
|
87
|
+
from arxiv2text import arxiv_to_text
|
|
88
|
+
|
|
89
|
+
search_results = self._get_search_results(
|
|
90
|
+
query, paper_ids, max_results
|
|
91
|
+
)
|
|
92
|
+
papers_data = []
|
|
93
|
+
|
|
94
|
+
for paper in search_results:
|
|
95
|
+
paper_info = {
|
|
96
|
+
"title": paper.title,
|
|
97
|
+
"published_date": paper.updated.date().isoformat(),
|
|
98
|
+
"authors": [author.name for author in paper.authors],
|
|
99
|
+
"entry_id": paper.entry_id,
|
|
100
|
+
"summary": paper.summary,
|
|
101
|
+
# TODO: Use chunkr instead of atxiv_to_text for better
|
|
102
|
+
# performance
|
|
103
|
+
"paper_text": arxiv_to_text(paper.pdf_url),
|
|
104
|
+
}
|
|
105
|
+
papers_data.append(paper_info)
|
|
106
|
+
|
|
107
|
+
return papers_data
|
|
108
|
+
|
|
109
|
+
def download_papers(
|
|
110
|
+
self,
|
|
111
|
+
query: str,
|
|
112
|
+
paper_ids: Optional[List[str]] = None,
|
|
113
|
+
max_results: Optional[int] = 5,
|
|
114
|
+
output_dir: Optional[str] = "./",
|
|
115
|
+
) -> str:
|
|
116
|
+
r"""Downloads PDFs of academic papers from arXiv based on the provided
|
|
117
|
+
query.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
query (str): The search query string.
|
|
121
|
+
paper_ids (List[str], optional): A list of specific arXiv paper
|
|
122
|
+
IDs to download. (default::obj: `None`)
|
|
123
|
+
max_results (int, optional): The maximum number of search results
|
|
124
|
+
to download. (default::obj: `5`)
|
|
125
|
+
output_dir (str, optional): The directory to save the downloaded
|
|
126
|
+
PDFs. Defaults to the current directory.
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
str: Status message indicating success or failure.
|
|
130
|
+
"""
|
|
131
|
+
try:
|
|
132
|
+
search_results = self._get_search_results(
|
|
133
|
+
query, paper_ids, max_results
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
for paper in search_results:
|
|
137
|
+
paper.download_pdf(
|
|
138
|
+
dirpath=output_dir, filename=f"{paper.title}" + ".pdf"
|
|
139
|
+
)
|
|
140
|
+
return "papers downloaded successfully"
|
|
141
|
+
except Exception as e:
|
|
142
|
+
return f"An error occurred: {e}"
|
|
143
|
+
|
|
144
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
145
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
146
|
+
functions in the toolkit.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
150
|
+
representing the functions in the toolkit.
|
|
151
|
+
"""
|
|
152
|
+
return [
|
|
153
|
+
FunctionTool(self.search_papers),
|
|
154
|
+
FunctionTool(self.download_papers),
|
|
155
|
+
]
|