From 98cabc89ed6f2647ef6c23b6dc03c7a1fbce939d Mon Sep 17 00:00:00 2001 From: Jacky Wong Date: Tue, 29 Aug 2023 09:34:36 +1000 Subject: [PATCH 1/4] fix deepeval --- deepeval/cli/main.py | 4 +++- deepeval/client.py | 2 ++ deepeval/metrics/metric.py | 11 ++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/deepeval/cli/main.py b/deepeval/cli/main.py index 64ee1f1d5..324e9f6fd 100644 --- a/deepeval/cli/main.py +++ b/deepeval/cli/main.py @@ -34,13 +34,15 @@ def login( if api_key == "": api_key = KEY_FILE_HANDLER.fetch_api_key() api_key = typer.prompt( - text="Paste it here (Hit enter if default is right) ", + text="Paste it here (Hit enter if default is right)", default=api_key, ) KEY_FILE_HANDLER.write_api_key(api_key) client = Api(api_key=api_key) if project_name == "": project_name = KEY_FILE_HANDLER.fetch_implementation_name() + if project_name is None or project_name == "": + project_name = "example" print("What is the name of your project?") project_name = typer.prompt( text="Name (Hit enter if default is right):", diff --git a/deepeval/client.py b/deepeval/client.py index d4bae1e65..842d4ef26 100644 --- a/deepeval/client.py +++ b/deepeval/client.py @@ -3,6 +3,7 @@ import os import getpass from .api import Api +from .key_handler import KEY_FILE_HANDLER from typing import Optional, List, Dict @@ -13,6 +14,7 @@ class Client(Api): def __init__(self, api_key: str = None, local_mode: bool = False, **kwargs): if api_key is None: + api_key = KEY_FILE_HANDLER.fetch_api_key() if "CONFIDENT_AI_API_KEY" not in os.environ: api_key = getpass.getpass( "Grab your API key from https://app.confident-ai.com" diff --git a/deepeval/metrics/metric.py b/deepeval/metrics/metric.py index 279cfa537..1d7ef5430 100644 --- a/deepeval/metrics/metric.py +++ b/deepeval/metrics/metric.py @@ -1,6 +1,7 @@ import os import warnings from typing import Optional +from ..get_api_key import _get_api_key from ..constants import ( API_KEY_ENV, IMPLEMENTATION_ID_ENV, @@ -37,11 +38,11 @@ def is_successful(self) -> bool: raise NotImplementedError def _is_api_key_set(self): - result = os.getenv(API_KEY_ENV) is not None - if result is False: - warnings.warn( - """API key is not set. Please set it by visiting https://app.confident-ai.com""" - ) + result = _get_api_key() + # if result == "" or result is None: + # warnings.warn( + # """API key is not set - you won't be able to log to the DeepEval dashboard. Please set it by running `deepeval login`""" + # ) return result def _is_send_okay(self): From 4445a3739f93ef0bbd90b3a63fa54115f2e1453a Mon Sep 17 00:00:00 2001 From: Jacky Wong Date: Tue, 29 Aug 2023 09:36:30 +1000 Subject: [PATCH 2/4] add github token --- .github/workflows/pip_install.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/pip_install.yml diff --git a/.github/workflows/pip_install.yml b/.github/workflows/pip_install.yml new file mode 100644 index 000000000..bc095acdf --- /dev/null +++ b/.github/workflows/pip_install.yml @@ -0,0 +1,25 @@ +name: Pip install comment + +on: + pull_request: + +jobs: + create-pip-link-comment: + runs-on: ubuntu-latest + name: pip link + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Comment PR + uses: marocchino/sticky-pull-request-comment@v2 + with: + hide_and_recreate: true + hide_classify: "OUTDATED" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + message: | + Thanks for the PR! Going to review and merge soon 😉 + Just before that though can you please test the installation with the command below? 😎 + ``` + pip install git+https://github.com/RelevanceAI/relevance-workflows-core.git@${{ github.head_ref }} + ``` From c9fc66572d7369ff8bd84292a3d74fbaaeace24d Mon Sep 17 00:00:00 2001 From: Jacky Wong Date: Tue, 29 Aug 2023 09:41:06 +1000 Subject: [PATCH 3/4] get API key --- deepeval/_version.py | 2 +- deepeval/get_api_key.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 deepeval/get_api_key.py diff --git a/deepeval/_version.py b/deepeval/_version.py index 89080dd62..7bfcb756c 100644 --- a/deepeval/_version.py +++ b/deepeval/_version.py @@ -1 +1 @@ -__version__: str = "0.10.2" +__version__: str = "0.10.3" diff --git a/deepeval/get_api_key.py b/deepeval/get_api_key.py new file mode 100644 index 000000000..b8d83ca4f --- /dev/null +++ b/deepeval/get_api_key.py @@ -0,0 +1,13 @@ +"""Utility function for getting API key. +""" +import os +from .key_handler import KEY_FILE_HANDLER +from .constants import API_KEY_ENV + + +def _get_api_key(): + """Get an API key here.""" + api_key = KEY_FILE_HANDLER.fetch_api_key() + if api_key is None or api_key == "": + api_key = os.getenv(API_KEY_ENV, "") + return api_key From a35bb70529cc8af70e255e0e363e8c8e6f1d4512 Mon Sep 17 00:00:00 2001 From: Jacky Wong Date: Tue, 29 Aug 2023 09:51:24 +1000 Subject: [PATCH 4/4] get an API key --- deepeval/_version.py | 2 +- deepeval/client.py | 12 +++--------- deepeval/metrics/metric.py | 4 +++- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/deepeval/_version.py b/deepeval/_version.py index 7bfcb756c..973235116 100644 --- a/deepeval/_version.py +++ b/deepeval/_version.py @@ -1 +1 @@ -__version__: str = "0.10.3" +__version__: str = "0.10.4" diff --git a/deepeval/client.py b/deepeval/client.py index 842d4ef26..b06f22bc5 100644 --- a/deepeval/client.py +++ b/deepeval/client.py @@ -3,7 +3,7 @@ import os import getpass from .api import Api -from .key_handler import KEY_FILE_HANDLER +from .get_api_key import _get_api_key from typing import Optional, List, Dict @@ -13,14 +13,8 @@ class Client(Api): _implementation_id: Dict[str, str] = {} def __init__(self, api_key: str = None, local_mode: bool = False, **kwargs): - if api_key is None: - api_key = KEY_FILE_HANDLER.fetch_api_key() - if "CONFIDENT_AI_API_KEY" not in os.environ: - api_key = getpass.getpass( - "Grab your API key from https://app.confident-ai.com" - ) - else: - api_key = os.environ["CONFIDENT_AI_API_KEY"] + if api_key is None or api_key == "": + api_key = _get_api_key() self.api_key = api_key self.local_mode = local_mode if self.local_mode: diff --git a/deepeval/metrics/metric.py b/deepeval/metrics/metric.py index 1d7ef5430..8cba808cf 100644 --- a/deepeval/metrics/metric.py +++ b/deepeval/metrics/metric.py @@ -43,7 +43,9 @@ def _is_api_key_set(self): # warnings.warn( # """API key is not set - you won't be able to log to the DeepEval dashboard. Please set it by running `deepeval login`""" # ) - return result + if result == "" or result is None: + return False + return True def _is_send_okay(self): # DOing this until the API endpoint is fixed