From 4dee3a9449c2d9ad686ab3eccc8969a27425cc8f Mon Sep 17 00:00:00 2001 From: John Alling Date: Fri, 4 Oct 2024 11:20:16 -0400 Subject: [PATCH] refactor to not use multiple api env vars --- src/leapfrogai_evals/README.md | 2 +- src/leapfrogai_evals/main.py | 2 +- src/leapfrogai_evals/models/lfai.py | 2 +- src/leapfrogai_evals/runners/niah_runner.py | 6 +++--- src/leapfrogai_evals/runners/qa_runner.py | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/leapfrogai_evals/README.md b/src/leapfrogai_evals/README.md index 8cd853878..a7938cc90 100644 --- a/src/leapfrogai_evals/README.md +++ b/src/leapfrogai_evals/README.md @@ -18,7 +18,7 @@ cp .env.example .env Within `.env`, replace the necessary environment variables: ```bash -LEAPFROGAI_API_URL= +LEAPFROGAI_API_URL= LEAPFROGAI_API_KEY= ANTHROPIC_API_KEY= ``` diff --git a/src/leapfrogai_evals/main.py b/src/leapfrogai_evals/main.py index 3813474f9..e57497f91 100644 --- a/src/leapfrogai_evals/main.py +++ b/src/leapfrogai_evals/main.py @@ -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() diff --git a/src/leapfrogai_evals/models/lfai.py b/src/leapfrogai_evals/models/lfai.py index fca7c8de4..88cc65741 100644 --- a/src/leapfrogai_evals/models/lfai.py +++ b/src/leapfrogai_evals/models/lfai.py @@ -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): diff --git a/src/leapfrogai_evals/runners/niah_runner.py b/src/leapfrogai_evals/runners/niah_runner.py index 99bfae069..4f711bdff 100644 --- a/src/leapfrogai_evals/runners/niah_runner.py +++ b/src/leapfrogai_evals/runners/niah_runner.py @@ -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}") @@ -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", diff --git a/src/leapfrogai_evals/runners/qa_runner.py b/src/leapfrogai_evals/runners/qa_runner.py index f06dbb303..cd297689e 100644 --- a/src/leapfrogai_evals/runners/qa_runner.py +++ b/src/leapfrogai_evals/runners/qa_runner.py @@ -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}") @@ -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",