diff --git a/blendsql/ingredients/builtin/map/main.py b/blendsql/ingredients/builtin/map/main.py index 8c055c8c..e19007ca 100644 --- a/blendsql/ingredients/builtin/map/main.py +++ b/blendsql/ingredients/builtin/map/main.py @@ -14,6 +14,7 @@ from blendsql.ingredients.ingredient import MapIngredient from blendsql._program import Program from blendsql import generate +from blendsql._exceptions import IngredientException class MapProgram(Program): @@ -157,6 +158,10 @@ def run( Returns: Iterable[Any] containing the output of the Model for each value. """ + if model is None: + raise IngredientException( + "LLMMap requires a `Model` object, but nothing was passed!\nMost likely you forgot to set the `default_model` argument in `blend()`" + ) # Unpack default kwargs tablename, colname = self.unpack_default_kwargs(**kwargs) # Remote endpoints can't use patterns diff --git a/blendsql/ingredients/builtin/qa/main.py b/blendsql/ingredients/builtin/qa/main.py index 05413bbc..20eff5d2 100644 --- a/blendsql/ingredients/builtin/qa/main.py +++ b/blendsql/ingredients/builtin/qa/main.py @@ -9,6 +9,7 @@ from blendsql.ingredients.ingredient import QAIngredient from blendsql.db.utils import single_quote_escape from blendsql import generate +from blendsql._exceptions import IngredientException class QAProgram(Program): @@ -91,6 +92,10 @@ def run( long_answer: bool = False, **kwargs, ) -> Union[str, int, float]: + if model is None: + raise IngredientException( + "LLMQA requires a `Model` object, but nothing was passed!\nMost likely you forgot to set the `default_model` argument in `blend()`" + ) if context is not None: if value_limit is not None: context = context.iloc[:value_limit] diff --git a/blendsql/ingredients/builtin/validate/main.py b/blendsql/ingredients/builtin/validate/main.py index 33c12167..00971d48 100644 --- a/blendsql/ingredients/builtin/validate/main.py +++ b/blendsql/ingredients/builtin/validate/main.py @@ -5,6 +5,7 @@ from blendsql._program import Program from blendsql.ingredients.ingredient import QAIngredient from blendsql import generate +from blendsql._exceptions import IngredientException class ValidateProgram(Program): @@ -38,6 +39,10 @@ def run( long_answer: bool = False, **kwargs, ) -> Union[str, int, float]: + if model is None: + raise IngredientException( + "LLMValidate requires a `Model` object, but nothing was passed!\nMost likely you forgot to set the `default_model` argument in `blend()`" + ) if context is not None: if value_limit is not None: context = context.iloc[:value_limit] diff --git a/blendsql/ingredients/builtin/vqa/main.py b/blendsql/ingredients/builtin/vqa/main.py index 2482124a..d3495bbe 100644 --- a/blendsql/ingredients/builtin/vqa/main.py +++ b/blendsql/ingredients/builtin/vqa/main.py @@ -28,6 +28,10 @@ class ImageCaption(MapIngredient): def run(self, model: Model, values: List[bytes], **kwargs): """Generates a caption for all byte images passed to it.""" + if model is None: + raise IngredientException( + "ImageCaption requires a `Model` object, but nothing was passed!\nMost likely you forgot to set the `default_model` argument in `blend()`" + ) if not all(isinstance(value, bytes) for value in values): raise IngredientException( f"All values must be 'byte' type for ImageCaption!"