Skip to content

Commit

Permalink
correct embedding access pattern
Browse files Browse the repository at this point in the history
fix embeddings access pattern in the other validator
  • Loading branch information
zsimjee committed Nov 21, 2023
1 parent ccf3c94 commit 76d2933
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions guardrails/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def __init__(

self._document = document
embedding_response = self.client.create_embedding(input=[document], model=model)
embedding = embedding_response["data"][0]["embedding"] # type: ignore
embedding = embedding_response[0] # type: ignore
self._document_embedding = np.array(embedding)
self._model = model
self._threshold = float(threshold)
Expand All @@ -736,7 +736,7 @@ def validate(self, value: Any, metadata: Dict) -> ValidationResult:
)

value_embedding = np.array(
embedding_response["data"][0]["embedding"] # type: ignore
embedding_response[0] # type: ignore
)

similarity = self.cosine_similarity(
Expand Down

0 comments on commit 76d2933

Please sign in to comment.