diff --git a/README.md b/README.md index e8900b6..fadc026 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ export CO_API_KEY= export ANTHROPIC_API_KEY= ``` +**You can also store all your API keys in a .env file.** +It will be loaded using the [python-dotenv library](https://github.com/theskumar/python-dotenv). Say we want to obtain the preferences of `gpt-4-2024-04-09`: ```sh diff --git a/requirements.txt b/requirements.txt index 51e6c6d..e5c4491 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ anthropic==0.31.0 google-generativeai==0.7.2 together==1.2.1 cohere==5.6.1 -git+https://github.com/lm-sys/FastChat.git@92a6d1fcd69a88ea169c0b01065ce44f1e690a2c \ No newline at end of file +git+https://github.com/lm-sys/FastChat.git@92a6d1fcd69a88ea169c0b01065ce44f1e690a2c +python-dotenv \ No newline at end of file diff --git a/scripts/generative.py b/scripts/generative.py index ed15cb3..60fc25b 100644 --- a/scripts/generative.py +++ b/scripts/generative.py @@ -31,6 +31,7 @@ from openai import OpenAI from together import Together + ANTHROPIC_MODEL_LIST = ( "claude-1", "claude-2", diff --git a/scripts/run_generative.py b/scripts/run_generative.py index e9a47c3..e9bb7c4 100644 --- a/scripts/run_generative.py +++ b/scripts/run_generative.py @@ -35,6 +35,7 @@ from pathlib import Path import numpy as np +from dotenv import load_dotenv from datasets import load_dataset from fastchat.conversation import get_conv_template from transformers import AutoTokenizer @@ -44,6 +45,8 @@ from scripts.generative import OPENAI_MODEL_LIST, format_judge_answers from scripts.generative import process_judgement, run_judge_pair +load_dotenv(verbose=True) + # get token from HF_TOKEN env variable, but if it doesn't exist pass none HF_TOKEN = os.getenv("HF_TOKEN", None) if not HF_TOKEN: diff --git a/tests/test_generative.py b/tests/test_generative.py index a6798e0..179509d 100644 --- a/tests/test_generative.py +++ b/tests/test_generative.py @@ -1,10 +1,13 @@ """Testing new functions in generative.py""" import pytest +from dotenv import load_dotenv from scripts.generative import chat_completion_cohere, format_judge_answers from scripts.generative import process_judgement, run_judge_pair +load_dotenv(verbose=True) + def test_format_judge_answers_multilingual_includes_language(): question = "Ano ang sagot sa (2+3) * 4? Ipaliwanag ang iyong sagot"