mirror of
https://github.com/hwchase17/langchain
synced 2024-11-02 09:40:22 +00:00
langchain[patch]: Migrate output parsers to support optional community imports (#21103)
Migrate output parsers
This commit is contained in:
parent
3853fe9f64
commit
9e788f09c6
@ -12,6 +12,8 @@
|
||||
|
||||
Serializable, Generation, PromptValue
|
||||
""" # noqa: E501
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_core.output_parsers import (
|
||||
CommaSeparatedListOutputParser,
|
||||
ListOutputParser,
|
||||
@ -26,6 +28,7 @@ from langchain_core.output_parsers.openai_tools import (
|
||||
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
|
||||
@ -39,6 +42,24 @@ from langchain.output_parsers.retry import RetryOutputParser, RetryWithErrorOutp
|
||||
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",
|
||||
|
@ -1,10 +1,40 @@
|
||||
from langchain_community.output_parsers.ernie_functions import (
|
||||
JsonKeyOutputFunctionsParser,
|
||||
JsonOutputFunctionsParser,
|
||||
OutputFunctionsParser,
|
||||
PydanticAttrOutputFunctionsParser,
|
||||
PydanticOutputFunctionsParser,
|
||||
)
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.output_parsers.ernie_functions import (
|
||||
JsonKeyOutputFunctionsParser,
|
||||
JsonOutputFunctionsParser,
|
||||
OutputFunctionsParser,
|
||||
PydanticAttrOutputFunctionsParser,
|
||||
PydanticOutputFunctionsParser,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"JsonKeyOutputFunctionsParser": (
|
||||
"langchain_community.output_parsers.ernie_functions"
|
||||
),
|
||||
"JsonOutputFunctionsParser": "langchain_community.output_parsers.ernie_functions",
|
||||
"OutputFunctionsParser": "langchain_community.output_parsers.ernie_functions",
|
||||
"PydanticAttrOutputFunctionsParser": (
|
||||
"langchain_community.output_parsers.ernie_functions"
|
||||
),
|
||||
"PydanticOutputFunctionsParser": (
|
||||
"langchain_community.output_parsers.ernie_functions"
|
||||
),
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"JsonKeyOutputFunctionsParser",
|
||||
|
@ -1,5 +1,25 @@
|
||||
from langchain_community.output_parsers.rail_parser import (
|
||||
GuardrailsOutputParser,
|
||||
)
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
__all__ = ["GuardrailsOutputParser"]
|
||||
from langchain._api import create_importer
|
||||
|
||||
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__ = [
|
||||
"GuardrailsOutputParser",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user