Skip to content

Commit

Permalink
CERT-7874 Handle LLM key crash
Browse files Browse the repository at this point in the history
  • Loading branch information
nivcertora committed Dec 29, 2024
1 parent bb97d09 commit 016eab3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Quorum/checks/new_listing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
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



class NewListingCheck(Check):

def new_listing_check(self) -> None:
Expand All @@ -15,6 +17,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 an LLM API key, you can add it to you env 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')

0 comments on commit 016eab3

Please sign in to comment.