Spaces:
Runtime error
Runtime error
File size: 1,846 Bytes
63deadc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
"""
**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._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",
"get_bolded_text",
"get_color_mapping",
"get_colored_text",
"get_from_dict_or_env",
"get_from_env",
"formatter",
"get_pydantic_field_names",
"guard_import",
"mock_now",
"print_text",
"raise_for_status_with_text",
"stringify_dict",
"stringify_value",
"xor_args",
]
|