Skip to content

Commit 2edbffd

Browse files
authored
Merge pull request #481 from guardrails-ai/shreya/safe-get-async-validate
2 parents 5de4cb6 + a4ab2ab commit 2edbffd

File tree

10 files changed

+210
-210
lines changed

10 files changed

+210
-210
lines changed

.github/workflows/scripts/run_notebooks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cd docs/examples
99
# Function to process a notebook
1010
process_notebook() {
1111
notebook="$1"
12-
invalid_notebooks=("valid_chess_moves.ipynb" "translation_with_quality_check.ipynb" "llamaindex-output-parsing.ipynb" "competitors_check.ipynb")
12+
invalid_notebooks=("valid_chess_moves.ipynb" "translation_with_quality_check.ipynb" "llamaindex-output-parsing.ipynb")
1313
if [[ ! " ${invalid_notebooks[@]} " =~ " ${notebook} " ]]; then
1414
echo "Processing $notebook..."
1515
poetry run jupyter nbconvert --to notebook --execute "$notebook"

guardrails/document_store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,21 +241,21 @@ class FallbackEphemeralDocumentStore:
241241
def __init__(self):
242242
raise ImportError(
243243
"SQLAlchemy is required for EphemeralDocumentStore"
244-
"Please install it using `pip install SqlAlchemy`"
244+
"Please install it using `poetry add SqlAlchemy`"
245245
)
246246

247247
class FallbackSQLDocument:
248248
def __init__(self):
249249
raise ImportError(
250250
"SQLAlchemy is required for SQLDocument"
251-
"Please install it using `pip install SqlAlchemy`"
251+
"Please install it using `poetry add SqlAlchemy`"
252252
)
253253

254254
class FallbackSQLMetadataStore:
255255
def __init__(self):
256256
raise ImportError(
257257
"SQLAlchemy is required for SQLMetadataStore"
258-
"Please install it using `pip install SqlAlchemy`"
258+
"Please install it using `poetry add SqlAlchemy`"
259259
)
260260

261261
EphemeralDocumentStore = FallbackEphemeralDocumentStore

guardrails/embedding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(
2020
except ImportError:
2121
raise ImportError(
2222
f"`numpy` is required for `{self.__class__.__name__}` class."
23-
"Please install it with `pip install numpy`."
23+
"Please install it with `poetry add numpy`."
2424
)
2525

2626
self._model = model
@@ -55,7 +55,7 @@ def _len_safe_get_embedding(
5555
except ImportError:
5656
raise ImportError(
5757
f"`numpy` is required for `{self.__class__.__name__}` class."
58-
"Please install it with `pip install numpy`."
58+
"Please install it with `poetry add numpy`."
5959
)
6060

6161
chunk_embeddings_list = []
@@ -179,7 +179,7 @@ def __init__(
179179
except ImportError:
180180
raise ImportError(
181181
"The `manifest` package is not installed. "
182-
"Install with `pip install manifest-ml`"
182+
"Install with `poetry add manifest-ml`"
183183
)
184184
super().__init__(engine, encoding_name, max_tokens)
185185
self._client_name = client_name

guardrails/llm_providers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def _invoke_llm(
204204
except ImportError:
205205
raise PromptCallableException(
206206
"The `manifest` package is not installed. "
207-
"Install with `pip install manifest-ml`"
207+
"Install with `poetry add manifest-ml`"
208208
)
209209
client = cast(manifest.Manifest, client)
210210
manifest_response = client.run(
@@ -469,7 +469,7 @@ async def invoke_llm(
469469
except ImportError:
470470
raise PromptCallableException(
471471
"The `manifest` package is not installed. "
472-
"Install with `pip install manifest-ml`"
472+
"Install with `poetry add manifest-ml`"
473473
)
474474
client = cast(manifest.Manifest, client)
475475
manifest_response = await client.arun_batch(

guardrails/utils/docs_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def sentence_split(text: str) -> t.List[str]:
7575
except ImportError:
7676
raise ImportError(
7777
"nltk is required for sentence splitting. Please install it using "
78-
"`pip install nltk`"
78+
"`poetry add nltk`"
7979
)
8080

8181
# Download the nltk punkt tokenizer if it's not already downloaded.
@@ -123,11 +123,11 @@ def get_chunks_from_text(
123123

124124
nltk_error = (
125125
"nltk is required for sentence splitting. Please install it using "
126-
"`pip install nltk`"
126+
"`poetry add nltk`"
127127
)
128128
tiktoken_error = (
129129
"tiktoken is required for token splitting. Please install it using "
130-
"`pip install tiktoken`"
130+
"`poetry add tiktoken`"
131131
)
132132

133133
if chunk_strategy == "sentence":

guardrails/utils/sql_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, schema_file: Optional[str], conn: Optional[str]) -> None:
5555
if not _HAS_SQLALCHEMY:
5656
raise ImportError(
5757
"""The functionality requires sqlalchemy to be installed.
58-
Please install it using `pip install SqlAlchemy`"""
58+
Please install it using `poetry add SqlAlchemy`"""
5959
)
6060

6161
if schema_file is not None and conn is None:

guardrails/validator_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ async def validate_dependents(
256256
iteration: Iteration,
257257
):
258258
async def process_child(child_setup):
259-
child_value = value[child_setup.key]
259+
child_value = safe_get(value, child_setup.key)
260260
new_child_value, new_metadata = await self.async_validate(
261261
child_value,
262262
metadata,

guardrails/validators/competitor_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Callable, Dict, List, Optional
33

44
from guardrails.logger import logger
5-
from guardrails.validator_base import (
5+
from guardrails.validators import (
66
FailResult,
77
PassResult,
88
ValidationResult,

guardrails/vectordb/faiss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
faiss_error = (
1414
"`faiss` is required for using vectordb.faiss."
15-
"Install it with `pip install faiss-cpu`."
15+
"Install it with `poetry add faiss-cpu`."
1616
)
1717

1818

0 commit comments

Comments
 (0)