Home / Function/ get_color_mapping() — langchain Function Reference

get_color_mapping() — langchain Function Reference

Architecture documentation for the get_color_mapping() function in input.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  be09d27e_1bd6_69b2_dba2_afab0f42cc98["get_color_mapping()"]
  221c6bb5_2ec7_fbe8_1fae_cef08a34f645["input.py"]
  be09d27e_1bd6_69b2_dba2_afab0f42cc98 -->|defined in| 221c6bb5_2ec7_fbe8_1fae_cef08a34f645
  style be09d27e_1bd6_69b2_dba2_afab0f42cc98 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/utils/input.py lines 14–35

def get_color_mapping(
    items: list[str], excluded_colors: list | None = None
) -> dict[str, str]:
    """Get mapping for items to a support color.

    Args:
        items: The items to map to colors.
        excluded_colors: The colors to exclude.

    Returns:
        The mapping of items to colors.

    Raises:
        ValueError: If no colors are available after applying exclusions.
    """
    colors = list(_TEXT_COLOR_MAPPING.keys())
    if excluded_colors is not None:
        colors = [c for c in colors if c not in excluded_colors]
    if not colors:
        msg = "No colors available after applying exclusions."
        raise ValueError(msg)
    return {item: colors[i % len(colors)] for i, item in enumerate(items)}

Domain

Subdomains

Frequently Asked Questions

What does get_color_mapping() do?
get_color_mapping() is a function in the langchain codebase, defined in libs/core/langchain_core/utils/input.py.
Where is get_color_mapping() defined?
get_color_mapping() is defined in libs/core/langchain_core/utils/input.py at line 14.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free