mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
Load environment variables from a .env
file using python-dotenv
package.
# Context: USER: load dotenv ASSISTANT: To load environment variables from a `.env` file using the `python-dotenv` package, you can add the following lines at the beginning of the `main()` function in the `coder.py` file: ```python import os from dotenv import load_dotenv load_dotenv() ``` You will also need to install the `python-dotenv` package if you haven't already. You can install it using pip: ``` pip install python-dotenv ``` Here's the change to the `coder.py` file: ```python coder.py <<<<<<< ORIGINAL def main(): env_prefix = "CODER_" ======= import os from dotenv import load_dotenv def main(): load_dotenv() env_prefix = "CODER_" >>>>>>> UPDATED ```
This commit is contained in:
parent
50ba2136b7
commit
bd88c4c40f
1 changed files with 6 additions and 3 deletions
9
coder.py
9
coder.py
|
@ -566,9 +566,12 @@ class Coder:
|
|||
return commit_hash, commit_message
|
||||
|
||||
|
||||
def main():
|
||||
env_prefix = "CODER_"
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
def main():
|
||||
load_dotenv()
|
||||
env_prefix = "CODER_"
|
||||
parser = argparse.ArgumentParser(description="Chat with GPT about code")
|
||||
parser.add_argument(
|
||||
"files", metavar="FILE", nargs="+", help="a list of source code files",
|
||||
|
@ -630,4 +633,4 @@ def main():
|
|||
|
||||
if __name__ == "__main__":
|
||||
status = main()
|
||||
sys.exit(status)
|
||||
sys.exit(status)
|
Loading…
Add table
Add a link
Reference in a new issue