Skip to content

Commit

Permalink
refactor to not use multiple api env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jalling97 committed Oct 4, 2024
1 parent dee460f commit 4dee3a9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/leapfrogai_evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cp .env.example .env
Within `.env`, replace the necessary environment variables:

```bash
LEAPFROGAI_API_URL=<LeapfrogAI API url, usually: https://leapfrogai-api.uds.dev/openai/v1 for development>
LEAPFROGAI_API_URL=<LeapfrogAI API url, usually: https://leapfrogai-api.uds.dev for development>
LEAPFROGAI_API_KEY=<LeapfrogAI API key>
ANTHROPIC_API_KEY=<Anthropic API key>
```
Expand Down
2 changes: 1 addition & 1 deletion src/leapfrogai_evals/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ def run_evals(self, *args, **kwargs) -> None:
logging.basicConfig(level=logging.INFO)
load_dotenv()
evaluator = RAGEvaluator()
evaluator.set_evaluations()
evaluator.set_evaluations(eval_list=["mmlu"])
evaluator.run_evals()
2 changes: 1 addition & 1 deletion src/leapfrogai_evals/models/lfai.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(
):
self.model = model or os.getenv("MODEL_TO_EVALUATE")
self.api_key = api_key or os.getenv("LEAPFROGAI_API_KEY")
self.base_url = base_url or os.getenv("LEAPFROGAI_API_URL")
self.base_url = base_url or os.getenv("LEAPFROGAI_API_URL") + "/openai/v1"
self.client = openai.OpenAI(api_key=self.api_key, base_url=self.base_url)

def load_model(self):
Expand Down
6 changes: 3 additions & 3 deletions src/leapfrogai_evals/runners/niah_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(
)

self.client = openai.OpenAI(
base_url=base_url or os.environ.get("LEAPFROGAI_API_URL"),
base_url=base_url or os.environ.get("LEAPFROGAI_API_URL") + "/openai/v1",
api_key=api_key or os.environ.get("LEAPFROGAI_API_KEY"),
)
logging.info(f"client url: {self.client.base_url}")
Expand Down Expand Up @@ -178,8 +178,8 @@ def run_experiment(self, cleanup: bool = True) -> None:
for chunk_num, chunk_id in enumerate(chunk_ids):
logging.info(f"chunk {chunk_num} (id: {chunk_id})")
vector_response = requests.get(
url=os.getenv("LEAPFROGAI_API_LFAI_URL")
+ "/vector_stores/vector/"
url=os.getenv("LEAPFROGAI_API_URL")
+ "/leapfrogai/v1/vector_stores/vector/"
+ chunk_id,
headers={
"accept": "application/json",
Expand Down
6 changes: 3 additions & 3 deletions src/leapfrogai_evals/runners/qa_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
)

self.client = openai.OpenAI(
base_url=base_url or os.getenv("LEAPFROGAI_API_URL"),
base_url=base_url or os.getenv("LEAPFROGAI_API_URL") + "/openai/v1",
api_key=self.api_key,
)
logging.info(f"client url: {self.client.base_url}")
Expand Down Expand Up @@ -145,8 +145,8 @@ def run_experiment(self) -> None:
# retrieve context used to generate response
for chunk_id in chunk_ids:
vector_response = requests.get(
url=os.getenv("LEAPFROGAI_API_LFAI_URL")
+ "/vector_stores/vector/"
url=os.getenv("LEAPFROGAI_API_URL")
+ "/leapfrogai/v1/vector_stores/vector/"
+ chunk_id,
headers={
"accept": "application/json",
Expand Down

0 comments on commit 4dee3a9

Please sign in to comment.