diff --git a/Quorum/checks/new_listing.py b/Quorum/checks/new_listing.py index a665f1b..551bf37 100644 --- a/Quorum/checks/new_listing.py +++ b/Quorum/checks/new_listing.py @@ -1,5 +1,6 @@ from Quorum.checks.check import Check import Quorum.utils.pretty_printer as pp +import Quorum.config as config from Quorum.llm.chains.first_deposit_chain import FirstDepositChain, ListingArray @@ -15,6 +16,15 @@ def new_listing_check(self) -> None: functions = self._get_functions_from_source_codes() if functions.get("newListings", functions.get("newListingsCustom")): pp.pretty_print(f"New listings detected for {self.proposal_address}", pp.Colors.WARNING) + + # Check if Anthropic API key is configured + if not config.ANTHROPIC_API_KEY: + pp.pretty_print( + "First deposit check is skipped. If you have a LLM API key, you can add it to your environment variables to enable this check", + pp.Colors.WARNING + ) + return + proposal_code = self.source_codes[0].file_content proposal_code_str = '\n'.join(proposal_code) listings: ListingArray | None = FirstDepositChain().execute(proposal_code_str) diff --git a/Quorum/config.py b/Quorum/config.py index f82d4a0..6ccce67 100644 --- a/Quorum/config.py +++ b/Quorum/config.py @@ -2,6 +2,7 @@ import shutil from pathlib import Path +import Quorum.utils.pretty_printer as pp main_path = os.getenv("QUORUM_PATH") if not main_path: @@ -19,4 +20,10 @@ shutil.copy(DEFAULT_REPOS, GROUND_TRUTH_PATH) ANTHROPIC_API_KEY = os.getenv('ANTHROPIC_API_KEY') +if not ANTHROPIC_API_KEY: + pp.pretty_print( + "Warning: ANTHROPIC_API_KEY environment variable is not set. All dependent checks will be skipped.", + pp.Colors.WARNING + ) + ANTHROPIC_MODEL = os.getenv('ANTROPIC_MDOEL', 'claude-3-5-sonnet-20241022') diff --git a/Quorum/ipfs_validator.py b/Quorum/ipfs_validator.py index d51ad53..96960fb 100644 --- a/Quorum/ipfs_validator.py +++ b/Quorum/ipfs_validator.py @@ -2,6 +2,7 @@ import Quorum.utils.arg_validations as arg_valid from Quorum.apis.block_explorers.chains_api import ChainAPI from Quorum.llm.chains.ipfs_validation_chain import IPFSValidationChain +import Quorum.config as config from pathlib import Path import argparse @@ -49,6 +50,9 @@ def get_raw_ipfs(proposal_id: int) -> str: def main(): + # Check if the Anthropic API key is set in environment variables + if not config.ANTHROPIC_API_KEY: + raise ValueError("ANTHROPIC_API_KEY environment variable is not set. Please set it to use this functionality.") args = parse_args() # Initialize Chain API and fetch source codes