camel-ai 0.1.7.1__py3-none-any.whl → 0.1.7.2__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
CHANGED
camel/toolkits/reddit_toolkit.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import os
|
|
16
16
|
import time
|
|
17
|
-
from typing import Any, Dict, List
|
|
17
|
+
from typing import Any, Dict, List, Union
|
|
18
18
|
|
|
19
19
|
from requests.exceptions import RequestException
|
|
20
20
|
|
|
@@ -50,20 +50,14 @@ class RedditToolkit(BaseToolkit):
|
|
|
50
50
|
self.retries = retries
|
|
51
51
|
self.delay = delay
|
|
52
52
|
|
|
53
|
-
client_id = os.environ.get("REDDIT_CLIENT_ID", "")
|
|
54
|
-
client_secret = os.environ.get("REDDIT_CLIENT_SECRET", "")
|
|
55
|
-
user_agent = os.environ.get("REDDIT_USER_AGENT", "")
|
|
56
|
-
|
|
57
|
-
if not all([client_id, client_secret, user_agent]):
|
|
58
|
-
print(
|
|
59
|
-
"Reddit API credentials are not set. "
|
|
60
|
-
"Please set the environment variables."
|
|
61
|
-
)
|
|
53
|
+
self.client_id = os.environ.get("REDDIT_CLIENT_ID", "")
|
|
54
|
+
self.client_secret = os.environ.get("REDDIT_CLIENT_SECRET", "")
|
|
55
|
+
self.user_agent = os.environ.get("REDDIT_USER_AGENT", "")
|
|
62
56
|
|
|
63
57
|
self.reddit = Reddit(
|
|
64
|
-
client_id=client_id,
|
|
65
|
-
client_secret=client_secret,
|
|
66
|
-
user_agent=user_agent,
|
|
58
|
+
client_id=self.client_id,
|
|
59
|
+
client_secret=self.client_secret,
|
|
60
|
+
user_agent=self.user_agent,
|
|
67
61
|
request_timeout=30, # Set a timeout to handle delays
|
|
68
62
|
)
|
|
69
63
|
|
|
@@ -96,7 +90,7 @@ class RedditToolkit(BaseToolkit):
|
|
|
96
90
|
subreddit_name: str,
|
|
97
91
|
post_limit: int = 5,
|
|
98
92
|
comment_limit: int = 5,
|
|
99
|
-
) -> List[Dict[str, Any]]:
|
|
93
|
+
) -> Union[List[Dict[str, Any]], str]:
|
|
100
94
|
r"""Collects the top posts and their comments from a specified
|
|
101
95
|
subreddit.
|
|
102
96
|
|
|
@@ -109,9 +103,16 @@ class RedditToolkit(BaseToolkit):
|
|
|
109
103
|
per post. Defaults to `5`.
|
|
110
104
|
|
|
111
105
|
Returns:
|
|
112
|
-
List[Dict[str, Any]]: A list of dictionaries, each
|
|
113
|
-
post title and its top comments.
|
|
106
|
+
Union[List[Dict[str, Any]], str]: A list of dictionaries, each
|
|
107
|
+
containing the post title and its top comments if success.
|
|
108
|
+
String warming if credentials are not set.
|
|
114
109
|
"""
|
|
110
|
+
if not all([self.client_id, self.client_secret, self.user_agent]):
|
|
111
|
+
return (
|
|
112
|
+
"Reddit API credentials are not set. "
|
|
113
|
+
"Please set the environment variables."
|
|
114
|
+
)
|
|
115
|
+
|
|
115
116
|
subreddit = self._retry_request(self.reddit.subreddit, subreddit_name)
|
|
116
117
|
top_posts = self._retry_request(subreddit.top, limit=post_limit)
|
|
117
118
|
data = []
|
|
@@ -162,7 +163,7 @@ class RedditToolkit(BaseToolkit):
|
|
|
162
163
|
post_limit: int = 10,
|
|
163
164
|
comment_limit: int = 10,
|
|
164
165
|
sentiment_analysis: bool = False,
|
|
165
|
-
) -> List[Dict[str, Any]]:
|
|
166
|
+
) -> Union[List[Dict[str, Any]], str]:
|
|
166
167
|
r"""Tracks discussions about specific keywords in specified subreddits.
|
|
167
168
|
|
|
168
169
|
Args:
|
|
@@ -177,10 +178,17 @@ class RedditToolkit(BaseToolkit):
|
|
|
177
178
|
the comments. Defaults to `False`.
|
|
178
179
|
|
|
179
180
|
Returns:
|
|
180
|
-
List[Dict[str, Any]]: A list of dictionaries
|
|
181
|
-
subreddit name, post title, comment body, and
|
|
182
|
-
comment that contains the specified keywords
|
|
181
|
+
Union[List[Dict[str, Any]], str]: A list of dictionaries
|
|
182
|
+
containing the subreddit name, post title, comment body, and
|
|
183
|
+
upvotes for each comment that contains the specified keywords
|
|
184
|
+
if success. String warming if credentials are not set.
|
|
183
185
|
"""
|
|
186
|
+
if not all([self.client_id, self.client_secret, self.user_agent]):
|
|
187
|
+
return (
|
|
188
|
+
"Reddit API credentials are not set. "
|
|
189
|
+
"Please set the environment variables."
|
|
190
|
+
)
|
|
191
|
+
|
|
184
192
|
data = []
|
|
185
193
|
|
|
186
194
|
for subreddit_name in subreddits:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: camel-ai
|
|
3
|
-
Version: 0.1.7.
|
|
3
|
+
Version: 0.1.7.2
|
|
4
4
|
Summary: Communicative Agents for AI Society Study
|
|
5
5
|
Home-page: https://www.camel-ai.org/
|
|
6
6
|
License: Apache-2.0
|
|
@@ -213,7 +213,7 @@ conda create --name camel python=3.10
|
|
|
213
213
|
conda activate camel
|
|
214
214
|
|
|
215
215
|
# Clone github repo
|
|
216
|
-
git clone -b v0.1.7.
|
|
216
|
+
git clone -b v0.1.7.2 https://github.com/camel-ai/camel.git
|
|
217
217
|
|
|
218
218
|
# Change directory into project directory
|
|
219
219
|
cd camel
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
camel/__init__.py,sha256=
|
|
1
|
+
camel/__init__.py,sha256=zfW2d4AsbhF7wUeIw34SSwn3py5dFNQskWwiYFd3hIE,780
|
|
2
2
|
camel/agents/__init__.py,sha256=SSU1wbhZXWwQnE0rRxkpyN57kEu72KklsZNcdLkXfTs,1551
|
|
3
3
|
camel/agents/base.py,sha256=X39qWSiT1WnDqaJ9k3gQrTpOQSwUKzNEVpp5AY6fDH8,1130
|
|
4
4
|
camel/agents/chat_agent.py,sha256=bfmj5PFu6Q2NVlHbPnQ6Re5_fslNyOFhSjsegq1Qdvc,37563
|
|
@@ -167,7 +167,7 @@ camel/toolkits/open_api_specs/web_scraper/paths/__init__.py,sha256=f3LXNDzN2XWWo
|
|
|
167
167
|
camel/toolkits/open_api_specs/web_scraper/paths/scraper.py,sha256=SQGbFkshLN4xm-Ya49ssbSvaU1nFVNFYhWsEPYVeFe0,1123
|
|
168
168
|
camel/toolkits/open_api_toolkit.py,sha256=rbQrhY6gHoZi9kiX9138pah9qZ2S8K5Vex1zFGWeCK8,23403
|
|
169
169
|
camel/toolkits/openai_function.py,sha256=eaE441qxLvuRKr_WrpYLGkr5P2Nav07VVdR29n76RkU,14767
|
|
170
|
-
camel/toolkits/reddit_toolkit.py,sha256=
|
|
170
|
+
camel/toolkits/reddit_toolkit.py,sha256=FMHK7k9UHN-IqdabqyBavpo0ZOloveuPsOe3Ou-tq4o,8975
|
|
171
171
|
camel/toolkits/retrieval_toolkit.py,sha256=UFByIxMB8m_C8HH-a65MeBJJACoJcVrcKMU9TGzm_SI,3828
|
|
172
172
|
camel/toolkits/search_toolkit.py,sha256=vXe026bQpLic09iwY5PN4RS6SXeHYBBkjfnOlJYB670,12943
|
|
173
173
|
camel/toolkits/slack_toolkit.py,sha256=JdgDJe7iExTmG7dDXOG6v5KpVjZ6_My_d_WFTYSxkw4,10839
|
|
@@ -191,6 +191,6 @@ camel/workforce/utils.py,sha256=Z-kODz5PMPtfeKKVqpcQq-b-B8oqC7XSwi_F3__Ijhs,3526
|
|
|
191
191
|
camel/workforce/worker_node.py,sha256=wsRqk2rugCvvkcmCzvn-y-gQuyuJGAG8PIr1KtgqJFw,3878
|
|
192
192
|
camel/workforce/workforce.py,sha256=SVJJgSSkYvk05RgL9oaJzHwzziH7u51KLINRuzLB8BI,1773
|
|
193
193
|
camel/workforce/workforce_prompt.py,sha256=cAWYEIA0rau5itEekSoUIFttBzpKM9RzB6x-mfukGSU,4665
|
|
194
|
-
camel_ai-0.1.7.
|
|
195
|
-
camel_ai-0.1.7.
|
|
196
|
-
camel_ai-0.1.7.
|
|
194
|
+
camel_ai-0.1.7.2.dist-info/METADATA,sha256=XBxQ1IOQc0vm7-a247ZAGW61wBa_vXjmKS-Mc_c8CLs,24658
|
|
195
|
+
camel_ai-0.1.7.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
196
|
+
camel_ai-0.1.7.2.dist-info/RECORD,,
|
|
File without changes
|