Skip to content

Commit 9b6425e

Browse files
committed
Update GuardrailSequence to be compatible with LangChain 0.0.353.
1 parent 4b9b458 commit 9b6425e

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

ads/llm/chain.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,8 @@ def load(cls, chain_dict: dict, **kwargs) -> "GuardrailSequence":
261261
from ads.llm.serialize import load
262262

263263
chain_spec = chain_dict[SPEC_CHAIN]
264-
chain = cls()
265-
for config in chain_spec:
266-
step = load(config, **kwargs)
267-
# Chain the step
268-
chain |= step
269-
return chain
264+
steps = [load(config, **kwargs) for config in chain_spec]
265+
return cls(*steps)
270266

271267
def __str__(self) -> str:
272268
return "\n".join([str(step.__class__) for step in self.steps])

tests/unitary/with_extras/langchain/test_guardrails.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ def test_fn(chain: GuardrailSequence):
175175

176176
self.assert_before_and_after_serialization(test_fn, chain)
177177

178-
def test_empty_sequence(self):
179-
"""Tests empty sequence."""
180-
seq = GuardrailSequence()
181-
self.assertEqual(seq.steps, [])
182178

183179
def test_save_to_file(self):
184180
"""Tests saving to file."""

0 commit comments

Comments
 (0)