mirror of
https://github.com/hwchase17/langchain
synced 2024-10-29 17:07:25 +00:00
fed137a8a9
Description: new chain for logical fallacy removal from model output in chain and docs Issue: n/a see above Dependencies: none Tag maintainer: @hinthornw in past from my end but not sure who that would be for maintenance of chains Twitter handle: no twitter feel free to call out my git user if shout out j-space-b Note: created documentation in docs/extras --------- Co-authored-by: Jon Bennion <jb@Jons-MacBook-Pro.local> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
27 lines
730 B
Python
27 lines
730 B
Python
"""Unit tests for the Logical Fallacy chain, same format as CAI"""
|
|
from langchain_experimental.fallacy_removal.base import FallacyChain
|
|
|
|
TEXT_ONE = """ This text is bad.\
|
|
|
|
Fallacy Revision request: Make it great.\
|
|
|
|
Fallacy Revision:"""
|
|
|
|
TEXT_TWO = """ This text is bad.\n\n"""
|
|
|
|
TEXT_THREE = """ This text is bad.\
|
|
|
|
Fallacy Revision request: Make it great again.\
|
|
|
|
Fallacy Revision: Better text"""
|
|
|
|
|
|
def test_fallacy_critique_parsing() -> None:
|
|
"""Test parsing of critique text."""
|
|
for text in [TEXT_ONE, TEXT_TWO, TEXT_THREE]:
|
|
fallacy_critique = FallacyChain._parse_critique(text)
|
|
|
|
assert (
|
|
fallacy_critique.strip() == "This text is bad."
|
|
), f"Failed on {text} with {fallacy_critique}"
|