Skip to content

Commit

Permalink
Include python-dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
ljvmiranda921 committed Jul 18, 2024
1 parent f39befc commit ef8921e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export CO_API_KEY=<your cohere api token>
export ANTHROPIC_API_KEY=<your anthropic token>
```

**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
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
git+https://github.com/lm-sys/FastChat.git@92a6d1fcd69a88ea169c0b01065ce44f1e690a2c
python-dotenv
1 change: 1 addition & 0 deletions scripts/generative.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from openai import OpenAI
from together import Together


ANTHROPIC_MODEL_LIST = (
"claude-1",
"claude-2",
Expand Down
3 changes: 3 additions & 0 deletions scripts/run_generative.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_generative.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit ef8921e

Please sign in to comment.