Home / Class/ TestStripThinkTags Class — langchain Architecture

TestStripThinkTags Class — langchain Architecture

Architecture documentation for the TestStripThinkTags class in test_output_parsers.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  e196f7b5_5f5c_a1ab_6284_a4fee37131df["TestStripThinkTags"]
  404c4f2e_2e78_7429_00c2_95ca3f208765["test_output_parsers.py"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|defined in| 404c4f2e_2e78_7429_00c2_95ca3f208765
  e1e3c596_46f7_8676_4ada_25f1fcd5c5e9["test_strip_simple_think_tags()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| e1e3c596_46f7_8676_4ada_25f1fcd5c5e9
  528ee05f_07cc_f9d1_6e29_d83a3e0deb1d["test_strip_multiple_think_tags()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| 528ee05f_07cc_f9d1_6e29_d83a3e0deb1d
  be126a16_a71e_68f4_34b2_669030db003b["test_strip_nested_like_think_tags()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| be126a16_a71e_68f4_34b2_669030db003b
  04c73096_2ad1_5ea0_eebb_e702cb25f3b5["test_strip_think_tags_no_closing_tag()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| 04c73096_2ad1_5ea0_eebb_e702cb25f3b5
  053324a3_3013_c8b5_f944_241c647ec98a["test_strip_think_tags_empty_content()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| 053324a3_3013_c8b5_f944_241c647ec98a
  d493e452_4250_c36e_b775_84b13f4ffbee["test_strip_think_tags_no_tags()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| d493e452_4250_c36e_b775_84b13f4ffbee
  cb799209_ef87_6fcc_4124_2f74343be04d["test_strip_think_tags_only_tags()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| cb799209_ef87_6fcc_4124_2f74343be04d
  a4cea751_f784_e3b0_4c35_712e9ce30468["test_strip_think_tags_multiline()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| a4cea751_f784_e3b0_4c35_712e9ce30468
  5b49227f_ddcd_df62_5b8e_7b45003a4ddd["test_strip_think_tags_with_special_chars()"]
  e196f7b5_5f5c_a1ab_6284_a4fee37131df -->|method| 5b49227f_ddcd_df62_5b8e_7b45003a4ddd

Relationship Graph

Source Code

libs/partners/perplexity/tests/unit_tests/test_output_parsers.py lines 15–79

class TestStripThinkTags:
    """Tests for the strip_think_tags function."""

    def test_strip_simple_think_tags(self) -> None:
        """Test stripping simple think tags."""
        text = "Hello <think>some reasoning</think> world"
        result = strip_think_tags(text)
        assert result == "Hello  world"

    def test_strip_multiple_think_tags(self) -> None:
        """Test stripping multiple think tags."""
        text = "<think>first</think> Hello <think>second</think> world\
            <think>third</think>"
        result = strip_think_tags(text)
        assert result == "Hello  world"

    def test_strip_nested_like_think_tags(self) -> None:
        """Test stripping think tags that might appear nested."""
        text = "<think>outer <think>inner</think> still outer</think> result"
        result = strip_think_tags(text)
        # The function removes from first <think> to first </think>
        # then continues from after that </think>
        assert result == "still outer</think> result"

    def test_strip_think_tags_no_closing_tag(self) -> None:
        """Test handling of think tags without closing tag."""
        text = "Hello <think>unclosed reasoning world"
        result = strip_think_tags(text)
        # Treats unclosed tag as literal text
        assert result == "Hello <think>unclosed reasoning world"

    def test_strip_think_tags_empty_content(self) -> None:
        """Test stripping empty think tags."""
        text = "Hello <think></think> world"
        result = strip_think_tags(text)
        assert result == "Hello  world"

    def test_strip_think_tags_no_tags(self) -> None:
        """Test text without any think tags."""
        text = "Hello world"
        result = strip_think_tags(text)
        assert result == "Hello world"

    def test_strip_think_tags_only_tags(self) -> None:
        """Test text containing only think tags."""
        text = "<think>reasoning</think>"
        result = strip_think_tags(text)
        assert result == ""

    def test_strip_think_tags_multiline(self) -> None:
        """Test stripping think tags across multiple lines."""
        text = """Hello
<think>
reasoning line 1
reasoning line 2
</think>
world"""
        result = strip_think_tags(text)
        assert result == "Hello\n\nworld"

    def test_strip_think_tags_with_special_chars(self) -> None:
        """Test think tags containing special characters."""
        text = 'Before <think>{"key": "value"}</think> After'
        result = strip_think_tags(text)
        assert result == "Before  After"

Frequently Asked Questions

What is the TestStripThinkTags class?
TestStripThinkTags is a class in the langchain codebase, defined in libs/partners/perplexity/tests/unit_tests/test_output_parsers.py.
Where is TestStripThinkTags defined?
TestStripThinkTags is defined in libs/partners/perplexity/tests/unit_tests/test_output_parsers.py at line 15.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free