initial commit
This commit is contained in:
76
venv/Lib/site-packages/langchain_classic/utils/__init__.py
Normal file
76
venv/Lib/site-packages/langchain_classic/utils/__init__.py
Normal file
@@ -0,0 +1,76 @@
|
||||
"""Utility functions for LangChain.
|
||||
|
||||
These functions do not depend on any other LangChain module.
|
||||
"""
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_core.utils import (
|
||||
comma_list,
|
||||
get_from_dict_or_env,
|
||||
get_from_env,
|
||||
stringify_dict,
|
||||
stringify_value,
|
||||
)
|
||||
from langchain_core.utils.formatting import StrictFormatter, formatter
|
||||
from langchain_core.utils.input import (
|
||||
get_bolded_text,
|
||||
get_color_mapping,
|
||||
get_colored_text,
|
||||
print_text,
|
||||
)
|
||||
from langchain_core.utils.utils import (
|
||||
check_package_version,
|
||||
convert_to_secret_str,
|
||||
get_pydantic_field_names,
|
||||
guard_import,
|
||||
mock_now,
|
||||
raise_for_status_with_text,
|
||||
xor_args,
|
||||
)
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.utils.math import (
|
||||
cosine_similarity,
|
||||
cosine_similarity_top_k,
|
||||
)
|
||||
|
||||
# Not deprecated right now because we will likely need to move these functions
|
||||
# back into langchain (as long as we're OK with the dependency on numpy).
|
||||
_MODULE_LOOKUP = {
|
||||
"cosine_similarity": "langchain_community.utils.math",
|
||||
"cosine_similarity_top_k": "langchain_community.utils.math",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, module_lookup=_MODULE_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"StrictFormatter",
|
||||
"check_package_version",
|
||||
"comma_list",
|
||||
"convert_to_secret_str",
|
||||
"cosine_similarity",
|
||||
"cosine_similarity_top_k",
|
||||
"formatter",
|
||||
"get_bolded_text",
|
||||
"get_color_mapping",
|
||||
"get_colored_text",
|
||||
"get_from_dict_or_env",
|
||||
"get_from_env",
|
||||
"get_pydantic_field_names",
|
||||
"guard_import",
|
||||
"mock_now",
|
||||
"print_text",
|
||||
"raise_for_status_with_text",
|
||||
"stringify_dict",
|
||||
"stringify_value",
|
||||
"xor_args",
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3
venv/Lib/site-packages/langchain_classic/utils/aiter.py
Normal file
3
venv/Lib/site-packages/langchain_classic/utils/aiter.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from langchain_core.utils.aiter import NoLock, Tee, py_anext
|
||||
|
||||
__all__ = ["NoLock", "Tee", "py_anext"]
|
||||
3
venv/Lib/site-packages/langchain_classic/utils/env.py
Normal file
3
venv/Lib/site-packages/langchain_classic/utils/env.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from langchain_core.utils.env import get_from_dict_or_env, get_from_env
|
||||
|
||||
__all__ = ["get_from_dict_or_env", "get_from_env"]
|
||||
@@ -0,0 +1,36 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.utils.ernie_functions import (
|
||||
FunctionDescription,
|
||||
ToolDescription,
|
||||
convert_pydantic_to_ernie_function,
|
||||
convert_pydantic_to_ernie_tool,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"FunctionDescription": "langchain_community.utils.ernie_functions",
|
||||
"ToolDescription": "langchain_community.utils.ernie_functions",
|
||||
"convert_pydantic_to_ernie_function": "langchain_community.utils.ernie_functions",
|
||||
"convert_pydantic_to_ernie_tool": "langchain_community.utils.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__ = [
|
||||
"FunctionDescription",
|
||||
"ToolDescription",
|
||||
"convert_pydantic_to_ernie_function",
|
||||
"convert_pydantic_to_ernie_tool",
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
from langchain_core.utils.formatting import StrictFormatter
|
||||
|
||||
__all__ = ["StrictFormatter"]
|
||||
19
venv/Lib/site-packages/langchain_classic/utils/html.py
Normal file
19
venv/Lib/site-packages/langchain_classic/utils/html.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from langchain_core.utils.html import (
|
||||
DEFAULT_LINK_REGEX,
|
||||
PREFIXES_TO_IGNORE,
|
||||
PREFIXES_TO_IGNORE_REGEX,
|
||||
SUFFIXES_TO_IGNORE,
|
||||
SUFFIXES_TO_IGNORE_REGEX,
|
||||
extract_sub_links,
|
||||
find_all_links,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"DEFAULT_LINK_REGEX",
|
||||
"PREFIXES_TO_IGNORE",
|
||||
"PREFIXES_TO_IGNORE_REGEX",
|
||||
"SUFFIXES_TO_IGNORE",
|
||||
"SUFFIXES_TO_IGNORE_REGEX",
|
||||
"extract_sub_links",
|
||||
"find_all_links",
|
||||
]
|
||||
8
venv/Lib/site-packages/langchain_classic/utils/input.py
Normal file
8
venv/Lib/site-packages/langchain_classic/utils/input.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from langchain_core.utils.input import (
|
||||
get_bolded_text,
|
||||
get_color_mapping,
|
||||
get_colored_text,
|
||||
print_text,
|
||||
)
|
||||
|
||||
__all__ = ["get_bolded_text", "get_color_mapping", "get_colored_text", "print_text"]
|
||||
3
venv/Lib/site-packages/langchain_classic/utils/iter.py
Normal file
3
venv/Lib/site-packages/langchain_classic/utils/iter.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from langchain_core.utils.iter import NoLock, Tee, batch_iterate, tee_peer
|
||||
|
||||
__all__ = ["NoLock", "Tee", "batch_iterate", "tee_peer"]
|
||||
@@ -0,0 +1,11 @@
|
||||
from langchain_core.utils.json_schema import (
|
||||
_dereference_refs_helper,
|
||||
_retrieve_ref,
|
||||
dereference_refs,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"_dereference_refs_helper",
|
||||
"_retrieve_ref",
|
||||
"dereference_refs",
|
||||
]
|
||||
32
venv/Lib/site-packages/langchain_classic/utils/math.py
Normal file
32
venv/Lib/site-packages/langchain_classic/utils/math.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.utils.math import (
|
||||
cosine_similarity,
|
||||
cosine_similarity_top_k,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
# Not marked as deprecated since we may want to move the functionality
|
||||
# into langchain as long as we're OK with numpy as the dependency.
|
||||
_MODULE_LOOKUP = {
|
||||
"cosine_similarity": "langchain_community.utils.math",
|
||||
"cosine_similarity_top_k": "langchain_community.utils.math",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, module_lookup=_MODULE_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"cosine_similarity",
|
||||
"cosine_similarity_top_k",
|
||||
]
|
||||
23
venv/Lib/site-packages/langchain_classic/utils/openai.py
Normal file
23
venv/Lib/site-packages/langchain_classic/utils/openai.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.utils.openai import is_openai_v1
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"is_openai_v1": "langchain_community.utils.openai"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"is_openai_v1",
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
from langchain_core.utils.function_calling import FunctionDescription, ToolDescription
|
||||
from langchain_core.utils.function_calling import (
|
||||
convert_to_openai_function as convert_pydantic_to_openai_function,
|
||||
)
|
||||
from langchain_core.utils.function_calling import (
|
||||
convert_to_openai_tool as convert_pydantic_to_openai_tool,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"FunctionDescription",
|
||||
"ToolDescription",
|
||||
"convert_pydantic_to_openai_function",
|
||||
"convert_pydantic_to_openai_tool",
|
||||
]
|
||||
13
venv/Lib/site-packages/langchain_classic/utils/pydantic.py
Normal file
13
venv/Lib/site-packages/langchain_classic/utils/pydantic.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from langchain_core.utils.pydantic import PYDANTIC_VERSION
|
||||
|
||||
|
||||
def get_pydantic_major_version() -> int:
|
||||
"""Get the major version of Pydantic.
|
||||
|
||||
Returns:
|
||||
The major version of Pydantic.
|
||||
"""
|
||||
return PYDANTIC_VERSION.major
|
||||
|
||||
|
||||
__all__ = ["get_pydantic_major_version"]
|
||||
@@ -0,0 +1,3 @@
|
||||
from langchain_core.utils.strings import comma_list, stringify_dict, stringify_value
|
||||
|
||||
__all__ = ["comma_list", "stringify_dict", "stringify_value"]
|
||||
21
venv/Lib/site-packages/langchain_classic/utils/utils.py
Normal file
21
venv/Lib/site-packages/langchain_classic/utils/utils.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from langchain_core.utils.utils import (
|
||||
build_extra_kwargs,
|
||||
check_package_version,
|
||||
convert_to_secret_str,
|
||||
get_pydantic_field_names,
|
||||
guard_import,
|
||||
mock_now,
|
||||
raise_for_status_with_text,
|
||||
xor_args,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"build_extra_kwargs",
|
||||
"check_package_version",
|
||||
"convert_to_secret_str",
|
||||
"get_pydantic_field_names",
|
||||
"guard_import",
|
||||
"mock_now",
|
||||
"raise_for_status_with_text",
|
||||
"xor_args",
|
||||
]
|
||||
Reference in New Issue
Block a user