Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dotenv support #56

Merged
merged 8 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Quorum/.env.example
nivcertora marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export ETHSCAN_API_KEY="your_etherscan_api_key"
export ANTHROPIC_API_KEY="your_anthropic_api_key"
3 changes: 3 additions & 0 deletions Quorum/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from pathlib import Path

import Quorum.utils.pretty_printer as pp
from Quorum.utils.load_env import load_env_variables

load_env_variables()

main_path = os.getenv("QUORUM_PATH")
if not main_path:
Expand Down
27 changes: 27 additions & 0 deletions Quorum/utils/load_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
from dotenv import load_dotenv

import Quorum.utils.pretty_printer as pp

def load_env_variables():
# Capture the environment variables before loading .env
env_before = dict(os.environ)

# Load .env with override=True
load_dotenv(override=True)

# Capture the environment variables after loading .env
env_after = dict(os.environ)

# Identify overridden variables
overridden_vars = {
key: {'before': env_before[key], 'after': env_after[key]}
for key in env_before
if key in env_after and env_before[key] != env_after[key]
}

# Print the user if any environment variables were overridden
if overridden_vars:
pp.pretty_print("The following environment variables were overridden:", pp.Colors.WARNING)
for key, values in overridden_vars.items():
pp.pretty_print(f"{key}: {values['before']} -> {values['after']}", pp.Colors.WARNING)
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ export ANTHROPIC_API_KEY="your_anthropic_api_key"

Replace `your_etherscan_api_key`, `your_anthropic_api_key` with your actual API keys.

Alternatively, you can set these environment variables in a `.env` file in the current working directory where you use the tool:

nivcertora marked this conversation as resolved.
Show resolved Hide resolved
```sh
ETHSCAN_API_KEY=your_etherscan_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
```


Additionally, set the `QUORUM_PATH` environment variable to specify where the repositories and diffs will be saved:

```sh
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ jinja2
langchain-anthropic
langgraph
langchain_community
python-dotenv
Loading