Skip to content

Commit

Permalink
Merge branch 'main' into niv/CERT-7800-Add-Linea-Chain
Browse files Browse the repository at this point in the history
  • Loading branch information
nivcertora authored Dec 29, 2024
2 parents 67c5bec + 39c62c4 commit 2b87f0d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Quorum/checks/new_listing.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions Quorum/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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')
4 changes: 4 additions & 0 deletions Quorum/ipfs_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2b87f0d

Please sign in to comment.