🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
fix: Reddit tool credential warming
Wendong2b39b7fbbfda
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.ymlindex abb35d216..306400a18 100644--- a/.github/ISSUE_TEMPLATE/bug_report.yml+++ b/.github/ISSUE_TEMPLATE/bug_report.yml@@ -27,7 +27,7 @@ body:attributes:label: What version of camel are you using?description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.- placeholder: E.g., 0.1.7.1+ placeholder: E.g., 0.1.7.2validations:required: truediff --git a/README.md b/README.mdindex 34d0b3832..c67fae7a6 100644--- a/README.md+++ b/README.md@@ -119,7 +119,7 @@ conda create --name camel python=3.10conda activate camel# Clone github repo-git clone -b v0.1.7.1 https://github.com/camel-ai/camel.git+git clone -b v0.1.7.2 https://github.com/camel-ai/camel.git# Change directory into project directorycd cameldiff --git a/camel/__init__.py b/camel/__init__.pyindex 27ead3a8b..97c45b409 100644--- a/camel/__init__.py+++ b/camel/__init__.py@@ -12,7 +12,7 @@# limitations under the License.# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========-__version__ = '0.1.7.1'+__version__ = '0.1.7.2'__all__ = ['__version__',diff --git a/camel/toolkits/reddit_toolkit.py b/camel/toolkits/reddit_toolkit.pyindex c6003a214..402430ba6 100644--- a/camel/toolkits/reddit_toolkit.py+++ b/camel/toolkits/reddit_toolkit.py@@ -14,7 +14,7 @@import osimport time-from typing import Any, Dict, List+from typing import Any, Dict, List, Unionfrom requests.exceptions import RequestException@@ -50,20 +50,14 @@ class RedditToolkit(BaseToolkit):self.retries = retriesself.delay = delay- client_id = os.environ.get("REDDIT_CLIENT_ID", "")- client_secret = os.environ.get("REDDIT_CLIENT_SECRET", "")- user_agent = os.environ.get("REDDIT_USER_AGENT", "")-- if not all([client_id, client_secret, user_agent]):- print(- "Reddit API credentials are not set. "- "Please set the environment variables."- )+ self.client_id = os.environ.get("REDDIT_CLIENT_ID", "")+ self.client_secret = os.environ.get("REDDIT_CLIENT_SECRET", "")+ self.user_agent = os.environ.get("REDDIT_USER_AGENT", "")self.reddit = Reddit(- client_id=client_id,- client_secret=client_secret,- user_agent=user_agent,+ client_id=self.client_id,+ client_secret=self.client_secret,+ user_agent=self.user_agent,request_timeout=30, # Set a timeout to handle delays)@@ -96,7 +90,7 @@ class RedditToolkit(BaseToolkit):subreddit_name: str,post_limit: int = 5,comment_limit: int = 5,- ) -> List[Dict[str, Any]]:+ ) -> Union[List[Dict[str, Any]], str]:r"""Collects the top posts and their comments from a specifiedsubreddit.@@ -109,9 +103,16 @@ class RedditToolkit(BaseToolkit):per post. Defaults to `5`.Returns:- List[Dict[str, Any]]: A list of dictionaries, each containing the- post title and its top comments.+ Union[List[Dict[str, Any]], str]: A list of dictionaries, each+ containing the post title and its top comments if success.+ String warming if credentials are not set."""+ if not all([self.client_id, self.client_secret, self.user_agent]):+ return (+ "Reddit API credentials are not set. "+ "Please set the environment variables."+ )+subreddit = self._retry_request(self.reddit.subreddit, subreddit_name)top_posts = self._retry_request(subreddit.top, limit=post_limit)data = []@@ -162,7 +163,7 @@ class RedditToolkit(BaseToolkit):post_limit: int = 10,comment_limit: int = 10,sentiment_analysis: bool = False,- ) -> List[Dict[str, Any]]:+ ) -> Union[List[Dict[str, Any]], str]:r"""Tracks discussions about specific keywords in specified subreddits.Args:@@ -177,10 +178,17 @@ class RedditToolkit(BaseToolkit):the comments. Defaults to `False`.Returns:- List[Dict[str, Any]]: A list of dictionaries containing the- subreddit name, post title, comment body, and upvotes for each- comment that contains the specified keywords.+ Union[List[Dict[str, Any]], str]: A list of dictionaries+ containing the subreddit name, post title, comment body, and+ upvotes for each comment that contains the specified keywords+ if success. String warming if credentials are not set."""+ if not all([self.client_id, self.client_secret, self.user_agent]):+ return (+ "Reddit API credentials are not set. "+ "Please set the environment variables."+ )+data = []for subreddit_name in subreddits:diff --git a/docs/conf.py b/docs/conf.pyindex 8c0eac9f1..41122c26c 100644--- a/docs/conf.py+++ b/docs/conf.py@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))project = 'CAMEL'copyright = '2023, CAMEL-AI.org'author = 'CAMEL-AI.org'-release = '0.1.7.1'+release = '0.1.7.2'html_favicon = ('https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'diff --git a/docs/get_started/setup.md b/docs/get_started/setup.mdindex 8d341c2b3..079d0f828 100644--- a/docs/get_started/setup.md+++ b/docs/get_started/setup.md@@ -61,7 +61,7 @@ conda create --name camel python=3.10conda activate camel# Clone github repo-git clone -b v0.1.7.1 https://github.com/camel-ai/camel.git+git clone -b v0.1.7.2 https://github.com/camel-ai/camel.git# Change directory into project directorycd cameldiff --git a/pyproject.toml b/pyproject.tomlindex d0c5f7892..7ee2e0761 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"[tool.poetry]name = "camel-ai"-version = "0.1.7.1"+version = "0.1.7.2"authors = ["CAMEL-AI.org"]description = "Communicative Agents for AI Society Study"readme = "README.md"