Langchain v1.17 depreciation issue with Langserve: Importing GuardrailsOutputParser from langchain.output_parsers is deprecated #173

Closed
opened 2026-02-16 00:19:10 -05:00 by yindo · 7 comments
Owner

Originally created by @saurabhlalsaxena on GitHub (May 2, 2024).

Since I have upgraded to Langchain v1.17, when ever I start the serve with : "langchain serve", I get the below deprecation warning:

/usr/local/lib/python3.10/dist-packages/langchain/_api/module_import.py:87: LangChainDeprecationWarning: Importing GuardrailsOutputParser from langchain.output_parsers is deprecated. Please replace the import with the following:
from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser
warnings.warn(

My requirements file is as below:
chromadb==0.5.0
fastapi==0.110.3
langchain==0.1.17
langchain-cli==0.0.21
langchain-community==0.0.36
langchain-core==0.1.48
langchain-experimental==0.0.57
langchain-openai==0.1.4
langchain-text-splitters==0.0.1
langgraph==0.0.40
langserve==0.1.1
openai==1.25.0
opentelemetry-instrumentation-fastapi==0.45b0
pypdf==4.2.0
python-dotenv==1.0.1
python-multipart==0.0.9
uvicorn==0.23.2

Is there a way to avoid the warning?

Originally created by @saurabhlalsaxena on GitHub (May 2, 2024). Since I have upgraded to Langchain v1.17, when ever I start the serve with : "langchain serve", I get the below deprecation warning: /usr/local/lib/python3.10/dist-packages/langchain/_api/module_import.py:87: LangChainDeprecationWarning: Importing GuardrailsOutputParser from langchain.output_parsers is deprecated. Please replace the import with the following: from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser warnings.warn( My requirements file is as below: chromadb==0.5.0 fastapi==0.110.3 langchain==0.1.17 langchain-cli==0.0.21 langchain-community==0.0.36 langchain-core==0.1.48 langchain-experimental==0.0.57 langchain-openai==0.1.4 langchain-text-splitters==0.0.1 langgraph==0.0.40 langserve==0.1.1 openai==1.25.0 opentelemetry-instrumentation-fastapi==0.45b0 pypdf==4.2.0 python-dotenv==1.0.1 python-multipart==0.0.9 uvicorn==0.23.2 Is there a way to avoid the warning?
yindo closed this issue 2026-02-16 00:19:10 -05:00
Author
Owner

@eyurtsev commented on GitHub (May 2, 2024):

Ah downgrade for now to previous langchain version maybe 1.16 -- i need to fix this in langchain

@eyurtsev commented on GitHub (May 2, 2024): Ah downgrade for now to previous langchain version maybe 1.16 -- i need to fix this in langchain
Author
Owner

@eyurtsev commented on GitHub (May 3, 2024):

Actually just to double check do you have an import in your own code that looks like this:

from langchain.output_parsers import GuardrailsOutputParser

instead of importing it from community?

(Want to make sure that this is not in user code)

@eyurtsev commented on GitHub (May 3, 2024): Actually just to double check do you have an import in your own code that looks like this: `from langchain.output_parsers import GuardrailsOutputParser` instead of importing it from community? (Want to make sure that this is not in user code)
Author
Owner

@saurabhlalsaxena commented on GitHub (May 3, 2024):

I have double checked it in my code, I don't believe I am importing GuardrailsOutputParser.
I have imported JsonOutputFunctionsParser from langchain.output_parsers
and I am using the create_csv_agent
from langchain_experimental.agents.agent_toolkits import create_csv_agent
But I haven't imported GuardrailsOutputParser in my code.
Please let me know if this might be an issue at my end.

@saurabhlalsaxena commented on GitHub (May 3, 2024): I have double checked it in my code, I don't believe I am importing GuardrailsOutputParser. I have imported JsonOutputFunctionsParser from langchain.output_parsers and I am using the create_csv_agent from langchain_experimental.agents.agent_toolkits import create_csv_agent But I haven't imported GuardrailsOutputParser in my code. Please let me know if this might be an issue at my end.
Author
Owner

@saurabhlalsaxena commented on GitHub (May 3, 2024):

When I am search for it in my code. VS code is showing me that it is present in a file called rail_parser.py. Below is the import statement from the __init__.py file of output_parsers.
from langchain.output_parsers.rail_parser import GuardrailsOutputParser
So it is part of the langchain lib files and not being called in my code separately.
Hope this helps

@saurabhlalsaxena commented on GitHub (May 3, 2024): When I am search for it in my code. VS code is showing me that it is present in a file called rail_parser.py. Below is the import statement from the __init__.py file of output_parsers. from langchain.output_parsers.rail_parser import GuardrailsOutputParser So it is part of the langchain lib files and not being called in my code separately. Hope this helps
Author
Owner

@saurabhlalsaxena commented on GitHub (May 3, 2024):

The problem seems to be in the below __init__.py file for langchain.output_parsers.

"""**OutputParser** classes parse the output of an LLM call.

**Class hierarchy:**

.. code-block::

    BaseLLMOutputParser --> BaseOutputParser --> <name>OutputParser  # ListOutputParser, PydanticOutputParser

**Main helpers:**

.. code-block::

    Serializable, Generation, PromptValue
"""  # noqa: E501
from typing import TYPE_CHECKING, Any

from langchain_core.output_parsers import (
    CommaSeparatedListOutputParser,
    ListOutputParser,
    MarkdownListOutputParser,
    NumberedListOutputParser,
    PydanticOutputParser,
    XMLOutputParser,
)
from langchain_core.output_parsers.openai_tools import (
    JsonOutputKeyToolsParser,
    JsonOutputToolsParser,
    PydanticToolsParser,
)

from langchain._api import create_importer
from langchain.output_parsers.boolean import BooleanOutputParser
from langchain.output_parsers.combining import CombiningOutputParser
from langchain.output_parsers.datetime import DatetimeOutputParser
from langchain.output_parsers.enum import EnumOutputParser
from langchain.output_parsers.fix import OutputFixingParser
from langchain.output_parsers.pandas_dataframe import PandasDataFrameOutputParser
from langchain.output_parsers.rail_parser import GuardrailsOutputParser
from langchain.output_parsers.regex import RegexParser
from langchain.output_parsers.regex_dict import RegexDictParser
from langchain.output_parsers.retry import RetryOutputParser, RetryWithErrorOutputParser
from langchain.output_parsers.structured import ResponseSchema, StructuredOutputParser
from langchain.output_parsers.yaml import YamlOutputParser

if TYPE_CHECKING:
    from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser

# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
    "GuardrailsOutputParser": "langchain_community.output_parsers.rail_parser"
}

_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)


def __getattr__(name: str) -> Any:
    """Look up attributes dynamically."""
    return _import_attribute(name)


__all__ = [
    "BooleanOutputParser",
    "CombiningOutputParser",
    "CommaSeparatedListOutputParser",
    "DatetimeOutputParser",
    "EnumOutputParser",
    "GuardrailsOutputParser",
    "ListOutputParser",
    "MarkdownListOutputParser",
    "NumberedListOutputParser",
    "OutputFixingParser",
    "PandasDataFrameOutputParser",
    "PydanticOutputParser",
    "RegexDictParser",
    "RegexParser",
    "ResponseSchema",
    "RetryOutputParser",
    "RetryWithErrorOutputParser",
    "StructuredOutputParser",
    "XMLOutputParser",
    "JsonOutputToolsParser",
    "PydanticToolsParser",
    "JsonOutputKeyToolsParser",
    "YamlOutputParser",
]

There is deprecated lookup for GaurdrailsOutputParser. I am guessing it is for testing as no other module is being checked.
Not sure.

@saurabhlalsaxena commented on GitHub (May 3, 2024): The problem seems to be in the below __init__.py file for langchain.output_parsers. ``` """**OutputParser** classes parse the output of an LLM call. **Class hierarchy:** .. code-block:: BaseLLMOutputParser --> BaseOutputParser --> <name>OutputParser # ListOutputParser, PydanticOutputParser **Main helpers:** .. code-block:: Serializable, Generation, PromptValue """ # noqa: E501 from typing import TYPE_CHECKING, Any from langchain_core.output_parsers import ( CommaSeparatedListOutputParser, ListOutputParser, MarkdownListOutputParser, NumberedListOutputParser, PydanticOutputParser, XMLOutputParser, ) from langchain_core.output_parsers.openai_tools import ( JsonOutputKeyToolsParser, JsonOutputToolsParser, PydanticToolsParser, ) from langchain._api import create_importer from langchain.output_parsers.boolean import BooleanOutputParser from langchain.output_parsers.combining import CombiningOutputParser from langchain.output_parsers.datetime import DatetimeOutputParser from langchain.output_parsers.enum import EnumOutputParser from langchain.output_parsers.fix import OutputFixingParser from langchain.output_parsers.pandas_dataframe import PandasDataFrameOutputParser from langchain.output_parsers.rail_parser import GuardrailsOutputParser from langchain.output_parsers.regex import RegexParser from langchain.output_parsers.regex_dict import RegexDictParser from langchain.output_parsers.retry import RetryOutputParser, RetryWithErrorOutputParser from langchain.output_parsers.structured import ResponseSchema, StructuredOutputParser from langchain.output_parsers.yaml import YamlOutputParser if TYPE_CHECKING: from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser # Create a way to dynamically look up deprecated imports. # Used to consolidate logic for raising deprecation warnings and # handling optional imports. DEPRECATED_LOOKUP = { "GuardrailsOutputParser": "langchain_community.output_parsers.rail_parser" } _import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) def __getattr__(name: str) -> Any: """Look up attributes dynamically.""" return _import_attribute(name) __all__ = [ "BooleanOutputParser", "CombiningOutputParser", "CommaSeparatedListOutputParser", "DatetimeOutputParser", "EnumOutputParser", "GuardrailsOutputParser", "ListOutputParser", "MarkdownListOutputParser", "NumberedListOutputParser", "OutputFixingParser", "PandasDataFrameOutputParser", "PydanticOutputParser", "RegexDictParser", "RegexParser", "ResponseSchema", "RetryOutputParser", "RetryWithErrorOutputParser", "StructuredOutputParser", "XMLOutputParser", "JsonOutputToolsParser", "PydanticToolsParser", "JsonOutputKeyToolsParser", "YamlOutputParser", ] ``` There is deprecated lookup for GaurdrailsOutputParser. I am guessing it is for testing as no other module is being checked. Not sure.
Author
Owner

@eyurtsev commented on GitHub (May 3, 2024):

Thanks! I'll fix in a bit!

@eyurtsev commented on GitHub (May 3, 2024): Thanks! I'll fix in a bit!
Author
Owner

@eyurtsev commented on GitHub (May 3, 2024):

Fix merged.

@eyurtsev commented on GitHub (May 3, 2024): Fix merged.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langserve#173