Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guardrails/classes/history/iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def completion_tokens_consumed(self) -> Optional[int]:
def raw_output(self) -> Optional[str]:
"""The exact output from the LLM."""
response = self.outputs.llm_response_info
if response is not None:
if response is not None and response.output:
return response.output
elif self.outputs.raw_output is not None:
return self.outputs.raw_output
Expand Down
2 changes: 1 addition & 1 deletion guardrails/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def merge(
advance = True
composed_text.append(source_text)
tempdiff = DIFFER.diff_main(target_text, source_text)
_, invariant = tempdiff[1]
_, invariant = tempdiff[1] if len(tempdiff) > 1 else tempdiff[0]
# _, (_, invariant) = DIFFER.diff_main(source_text, target_text)
prev_source_text = source[1]
source = next(diff1, None) # type: ignore
Expand Down
31 changes: 17 additions & 14 deletions tests/unit_tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@
],
"""<PERSON> is funny and lives in <LOCATION>""",
),
# broken!
# (
# """JOHN lives IN SAN francisco""",
# [
# """<PERSON> lives in <LOCATION>""",
# """john lives in san francisco""",
# ],
# """<PERSON> lives in <LOCATION>""",
# )
# (broken) test behavior with a word close to PERSON
# ("""Perry is FUNNY and LIVES in NEW york""",
# ["""<PERSON> is FUNNY and lives in <LOCATION>""",
# """perry is funny and lives in new york"""],
# """<PERSON> is funny and lives in <LOCATION>"""),
(
"""JOHN lives IN SAN francisco""",
[
"""<PERSON> lives in <LOCATION>""",
"""john lives in san francisco""",
],
"""<PERSON> lives in <LOCATION>""",
),
# (broken) test behavior with a word close to PERSON - seems to work!?
(
"""Parson is FUNNY and LIVES in NEW york""",
[
"""<PERSON> is FUNNY and lives in <LOCATION>""",
"""parson is funny and lives in new york""",
],
"""<PERSON> is funny and lives in <LOCATION>""",
),
],
)
def test_merge(original, new_values, expected):
Expand Down
Loading