-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
langchain[patch]: Migrate callbacks module to use optional imports fo…
…r community (#21086)
- Loading branch information
Showing
28 changed files
with
800 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,33 @@ | ||
from langchain_community.callbacks.aim_callback import ( | ||
AimCallbackHandler, | ||
BaseMetadataCallbackHandler, | ||
import_aim, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["import_aim", "BaseMetadataCallbackHandler", "AimCallbackHandler"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.callbacks.aim_callback import ( | ||
AimCallbackHandler, | ||
BaseMetadataCallbackHandler, | ||
import_aim, | ||
) | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"import_aim": "langchain_community.callbacks.aim_callback", | ||
"BaseMetadataCallbackHandler": "langchain_community.callbacks.aim_callback", | ||
"AimCallbackHandler": "langchain_community.callbacks.aim_callback", | ||
} | ||
|
||
_import_attribute = create_importer(__file__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"import_aim", | ||
"BaseMetadataCallbackHandler", | ||
"AimCallbackHandler", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
from langchain_community.callbacks.argilla_callback import ArgillaCallbackHandler | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["ArgillaCallbackHandler"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.callbacks.argilla_callback import ArgillaCallbackHandler | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"ArgillaCallbackHandler": "langchain_community.callbacks.argilla_callback" | ||
} | ||
|
||
_import_attribute = create_importer(__file__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"ArgillaCallbackHandler", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
from langchain_community.callbacks.arize_callback import ArizeCallbackHandler | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["ArizeCallbackHandler"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.callbacks.arize_callback import ArizeCallbackHandler | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"ArizeCallbackHandler": "langchain_community.callbacks.arize_callback" | ||
} | ||
|
||
_import_attribute = create_importer(__file__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"ArizeCallbackHandler", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
from langchain_community.callbacks.clearml_callback import ( | ||
ClearMLCallbackHandler, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["ClearMLCallbackHandler"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.callbacks.clearml_callback import ClearMLCallbackHandler | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"ClearMLCallbackHandler": "langchain_community.callbacks.clearml_callback" | ||
} | ||
|
||
_import_attribute = create_importer(__file__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"ClearMLCallbackHandler", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
from langchain_community.callbacks.confident_callback import DeepEvalCallbackHandler | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["DeepEvalCallbackHandler"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.callbacks.confident_callback import DeepEvalCallbackHandler | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"DeepEvalCallbackHandler": "langchain_community.callbacks.confident_callback" | ||
} | ||
|
||
_import_attribute = create_importer(__file__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"DeepEvalCallbackHandler", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
from langchain_community.callbacks.context_callback import ( | ||
ContextCallbackHandler, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["ContextCallbackHandler"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.callbacks.context_callback import ContextCallbackHandler | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"ContextCallbackHandler": "langchain_community.callbacks.context_callback" | ||
} | ||
|
||
_import_attribute = create_importer(__file__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"ContextCallbackHandler", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
from langchain_community.callbacks.flyte_callback import ( | ||
FlyteCallbackHandler, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["FlyteCallbackHandler"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.callbacks.flyte_callback import FlyteCallbackHandler | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"FlyteCallbackHandler": "langchain_community.callbacks.flyte_callback" | ||
} | ||
|
||
_import_attribute = create_importer(__file__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"FlyteCallbackHandler", | ||
] |
Oops, something went wrong.