diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 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.2 validations: required: true diff --git a/README.md b/README.md index 34d0b3832..c67fae7a6 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ conda create --name camel python=3.10 conda 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 directory cd camel diff --git a/camel/__init__.py b/camel/__init__.py index 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.py index c6003a214..402430ba6 100644 --- a/camel/toolkits/reddit_toolkit.py +++ b/camel/toolkits/reddit_toolkit.py @@ -14,7 +14,7 @@ import os import time -from typing import Any, Dict, List +from typing import Any, Dict, List, Union from requests.exceptions import RequestException @@ -50,20 +50,14 @@ def __init__(self, retries: int = 3, delay: int = 0): self.retries = retries self.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 @@ def collect_top_posts( 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 specified subreddit. @@ -109,9 +103,16 @@ def collect_top_posts( 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 @@ def track_keyword_discussions( 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 @@ def track_keyword_discussions( 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.py index 8c0eac9f1..41122c26c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,7 @@ 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.md index 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.10 conda 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 directory cd camel diff --git a/pyproject.toml b/pyproject.toml index 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"