diff --git a/application/parser/remote/reddit_loader.py b/application/parser/remote/reddit_loader.py index 0230653a..22f5b185 100644 --- a/application/parser/remote/reddit_loader.py +++ b/application/parser/remote/reddit_loader.py @@ -1,10 +1,19 @@ from application.parser.remote.base import BaseRemote from langchain_community.document_loaders import RedditPostsLoader +import json class RedditPostsLoaderRemote(BaseRemote): def load_data(self, inputs): - data = eval(inputs) + try: + data = json.loads(inputs) + except json.JSONDecodeError as e: + raise ValueError(f"Invalid JSON input: {e}") + + required_fields = ["client_id", "client_secret", "user_agent", "search_queries"] + missing_fields = [field for field in required_fields if field not in data] + if missing_fields: + raise ValueError(f"Missing required fields: {', '.join(missing_fields)}") client_id = data.get("client_id") client_secret = data.get("client_secret") user_agent = data.get("user_agent")