From 2858ef6015df5503b74287fb48b029675c5a6090 Mon Sep 17 00:00:00 2001 From: TheDude Date: Fri, 27 Dec 2024 14:33:17 +0530 Subject: [PATCH] PLUGINS] Bump Version [openai] --- plugins/openai/pyproject.toml | 3 ++- plugins/openai/superduper_openai/__init__.py | 2 +- plugins/openai/superduper_openai/model.py | 17 ++++++++--------- superduper/base/config.py | 3 ++- superduper/misc/retry.py | 5 +++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/openai/pyproject.toml b/plugins/openai/pyproject.toml index 1cc7508c5..ed22a766e 100644 --- a/plugins/openai/pyproject.toml +++ b/plugins/openai/pyproject.toml @@ -26,7 +26,8 @@ dependencies = [ [project.optional-dependencies] test = [ - "vcrpy>=5.1.0", + "vcrpy==5.1.0", + "urllib3==2.2.3", ] [project.urls] diff --git a/plugins/openai/superduper_openai/__init__.py b/plugins/openai/superduper_openai/__init__.py index 891e18817..8aa4cf285 100644 --- a/plugins/openai/superduper_openai/__init__.py +++ b/plugins/openai/superduper_openai/__init__.py @@ -1,5 +1,5 @@ from .model import OpenAIChatCompletion, OpenAIEmbedding -__version__ = "0.4.2" +__version__ = "0.4.3" __all__ = 'OpenAIChatCompletion', 'OpenAIEmbedding' diff --git a/plugins/openai/superduper_openai/model.py b/plugins/openai/superduper_openai/model.py index 165f1ab1b..05f470633 100644 --- a/plugins/openai/superduper_openai/model.py +++ b/plugins/openai/superduper_openai/model.py @@ -16,11 +16,11 @@ ) from openai._types import NOT_GIVEN from superduper.backends.query_dataset import QueryDataset +from superduper.base import exceptions from superduper.base.datalayer import Datalayer from superduper.components.model import APIBaseModel, Inputs from superduper.misc.compat import cache from superduper.misc.retry import Retry, safe_retry -from superduper.base import exceptions retry = Retry( exception_types=( @@ -68,6 +68,13 @@ def init(self, db=None): super().init() # dall-e is not currently included in list returned by OpenAI model endpoint + if 'OPENAI_API_KEY' not in os.environ or ( + 'api_key' not in self.client_kwargs.keys() + ): + raise exceptions.MissingSecretsException( + 'OPENAI_API_KEY not available neither in environment vars ' + 'nor in `client_kwargs`' + ) if self.model not in ( mo := _available_models(json.dumps(self.client_kwargs)) ) and self.model not in ('dall-e'): @@ -75,14 +82,6 @@ def init(self, db=None): raise ValueError(msg) self.syncClient = SyncOpenAI(**self.client_kwargs) - if 'OPENAI_API_KEY' not in os.environ and ( - 'api_key' not in self.client_kwargs.keys() and self.client_kwargs - ): - raise exceptions.MissingSecretsException( - 'OPENAI_API_KEY not available neither in environment vars ' - 'nor in `client_kwargs`' - ) - def predict_batches(self, dataset: t.Union[t.List, QueryDataset]) -> t.List: """Predict on a dataset. diff --git a/superduper/base/config.py b/superduper/base/config.py index 35088d282..55e72e19b 100644 --- a/superduper/base/config.py +++ b/superduper/base/config.py @@ -1,7 +1,7 @@ """Configuration variables for superduper.io. The classes in this file define the configuration variables for superduper.io, -which means that this file gets imported before alost anything else, and +hich means that this file gets imported before alost anything else, and canot contain any other imports from this project. """ @@ -148,6 +148,7 @@ class Config(BaseConfig): :param envs: The envs datas :param data_backend: The URI for the data backend + :param secrets_volume: The secrets volume mount for secrets env vars. :param lance_home: The home directory for the Lance vector indices, Default: .superduper/vector_indices :param artifact_store: The URI for the artifact store diff --git a/superduper/misc/retry.py b/superduper/misc/retry.py index 8e2968ab3..fab78bc76 100644 --- a/superduper/misc/retry.py +++ b/superduper/misc/retry.py @@ -59,11 +59,12 @@ def wrapper(*args, **kwargs): attempt = 0 while attempt < retries: try: - load_secrets() + if attempt > 0: + load_secrets() return func(*args, **kwargs) except exception_to_check as e: attempt += 1 - if attempt >= retries: + if attempt > retries: logging.error( f"Function {func.__name__} failed after {retries} retries." )