camel-ai 0.2.3a1__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of camel-ai might be problematic. Click here for more details.

Files changed (87) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +93 -69
  3. camel/agents/knowledge_graph_agent.py +4 -6
  4. camel/bots/__init__.py +16 -2
  5. camel/bots/discord_app.py +138 -0
  6. camel/bots/slack/__init__.py +30 -0
  7. camel/bots/slack/models.py +158 -0
  8. camel/bots/slack/slack_app.py +255 -0
  9. camel/configs/__init__.py +1 -2
  10. camel/configs/anthropic_config.py +2 -5
  11. camel/configs/base_config.py +6 -6
  12. camel/configs/groq_config.py +2 -3
  13. camel/configs/ollama_config.py +1 -2
  14. camel/configs/openai_config.py +2 -23
  15. camel/configs/samba_config.py +2 -2
  16. camel/configs/togetherai_config.py +1 -1
  17. camel/configs/vllm_config.py +1 -1
  18. camel/configs/zhipuai_config.py +2 -3
  19. camel/embeddings/openai_embedding.py +2 -2
  20. camel/loaders/__init__.py +2 -0
  21. camel/loaders/chunkr_reader.py +163 -0
  22. camel/loaders/firecrawl_reader.py +3 -3
  23. camel/loaders/unstructured_io.py +35 -33
  24. camel/messages/__init__.py +1 -0
  25. camel/models/__init__.py +2 -4
  26. camel/models/anthropic_model.py +32 -26
  27. camel/models/azure_openai_model.py +39 -36
  28. camel/models/base_model.py +31 -20
  29. camel/models/gemini_model.py +37 -29
  30. camel/models/groq_model.py +29 -23
  31. camel/models/litellm_model.py +44 -61
  32. camel/models/mistral_model.py +32 -29
  33. camel/models/model_factory.py +66 -76
  34. camel/models/nemotron_model.py +33 -23
  35. camel/models/ollama_model.py +42 -47
  36. camel/models/{openai_compatibility_model.py → openai_compatible_model.py} +31 -49
  37. camel/models/openai_model.py +48 -29
  38. camel/models/reka_model.py +30 -28
  39. camel/models/samba_model.py +82 -177
  40. camel/models/stub_model.py +2 -2
  41. camel/models/togetherai_model.py +37 -43
  42. camel/models/vllm_model.py +43 -50
  43. camel/models/zhipuai_model.py +33 -27
  44. camel/retrievers/auto_retriever.py +29 -97
  45. camel/retrievers/vector_retriever.py +58 -47
  46. camel/societies/babyagi_playing.py +6 -3
  47. camel/societies/role_playing.py +5 -3
  48. camel/storages/graph_storages/graph_element.py +2 -2
  49. camel/storages/key_value_storages/json.py +6 -1
  50. camel/toolkits/__init__.py +20 -7
  51. camel/toolkits/arxiv_toolkit.py +155 -0
  52. camel/toolkits/ask_news_toolkit.py +653 -0
  53. camel/toolkits/base.py +2 -3
  54. camel/toolkits/code_execution.py +6 -7
  55. camel/toolkits/dalle_toolkit.py +6 -6
  56. camel/toolkits/{openai_function.py → function_tool.py} +34 -11
  57. camel/toolkits/github_toolkit.py +9 -10
  58. camel/toolkits/google_maps_toolkit.py +7 -7
  59. camel/toolkits/google_scholar_toolkit.py +146 -0
  60. camel/toolkits/linkedin_toolkit.py +7 -7
  61. camel/toolkits/math_toolkit.py +8 -8
  62. camel/toolkits/open_api_toolkit.py +5 -5
  63. camel/toolkits/reddit_toolkit.py +7 -7
  64. camel/toolkits/retrieval_toolkit.py +5 -5
  65. camel/toolkits/search_toolkit.py +9 -9
  66. camel/toolkits/slack_toolkit.py +11 -11
  67. camel/toolkits/twitter_toolkit.py +378 -452
  68. camel/toolkits/weather_toolkit.py +6 -6
  69. camel/toolkits/whatsapp_toolkit.py +177 -0
  70. camel/types/__init__.py +6 -1
  71. camel/types/enums.py +40 -85
  72. camel/types/openai_types.py +3 -0
  73. camel/types/unified_model_type.py +104 -0
  74. camel/utils/__init__.py +0 -2
  75. camel/utils/async_func.py +7 -7
  76. camel/utils/commons.py +32 -3
  77. camel/utils/token_counting.py +30 -212
  78. camel/workforce/role_playing_worker.py +1 -1
  79. camel/workforce/single_agent_worker.py +1 -1
  80. camel/workforce/task_channel.py +4 -3
  81. camel/workforce/workforce.py +4 -4
  82. camel_ai-0.2.4.dist-info/LICENSE +201 -0
  83. {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/METADATA +27 -56
  84. {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/RECORD +85 -76
  85. {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/WHEEL +1 -1
  86. camel/bots/discord_bot.py +0 -206
  87. camel/models/open_source_model.py +0 -170
@@ -12,29 +12,37 @@
12
12
  # limitations under the License.
13
13
  # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
14
  # ruff: noqa: I001
15
- from .openai_function import (
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 GoogleMapsToolkit
23
+
23
24
  from .math_toolkit import MathToolkit, MATH_FUNCS
24
- from .open_api_toolkit import OpenAPIToolkit
25
- from .retrieval_toolkit import RetrievalToolkit
26
25
  from .search_toolkit import SearchToolkit, SEARCH_FUNCS
27
- from .twitter_toolkit import TwitterToolkit
28
26
  from .weather_toolkit import WeatherToolkit, WEATHER_FUNCS
29
- from .slack_toolkit import SlackToolkit
30
27
  from .dalle_toolkit import DalleToolkit, DALLE_FUNCS
28
+ from .ask_news_toolkit import AskNewsToolkit, AsyncAskNewsToolkit
29
+
31
30
  from .linkedin_toolkit import LinkedInToolkit
32
31
  from .reddit_toolkit import RedditToolkit
33
-
32
+ from .base import BaseToolkit
33
+ from .google_maps_toolkit import GoogleMapsToolkit
34
34
  from .code_execution import CodeExecutionToolkit
35
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
36
42
 
37
43
  __all__ = [
44
+ 'BaseToolkit',
45
+ 'FunctionTool',
38
46
  'OpenAIFunction',
39
47
  'get_openai_function_schema',
40
48
  'get_openai_tool_schema',
@@ -52,8 +60,13 @@ __all__ = [
52
60
  'LinkedInToolkit',
53
61
  'RedditToolkit',
54
62
  'CodeExecutionToolkit',
63
+ 'AskNewsToolkit',
64
+ 'AsyncAskNewsToolkit',
65
+ 'GoogleScholarToolkit',
66
+ 'ArxivToolkit',
55
67
  'MATH_FUNCS',
56
68
  'SEARCH_FUNCS',
57
69
  'WEATHER_FUNCS',
58
70
  'DALLE_FUNCS',
71
+ 'TWITTER_FUNCS',
59
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
+ ]