Home / File/ graph_ascii.py — langchain Source File

graph_ascii.py — langchain Source File

Architecture documentation for graph_ascii.py, a python file in the langchain codebase. 8 imports, 0 dependents.

File python CoreAbstractions Serialization 8 imports 5 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  f966196c_7eac_1723_030f_5343072d2057["graph_ascii.py"]
  6d7cdba5_8e52_34b5_6742_57caf6500c80["math"]
  f966196c_7eac_1723_030f_5343072d2057 --> 6d7cdba5_8e52_34b5_6742_57caf6500c80
  9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"]
  f966196c_7eac_1723_030f_5343072d2057 --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  f966196c_7eac_1723_030f_5343072d2057 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  eb8e2f46_e582_b3e6_084b_c061ebf67ff3["grandalf.graphs"]
  f966196c_7eac_1723_030f_5343072d2057 --> eb8e2f46_e582_b3e6_084b_c061ebf67ff3
  62e8f597_e2c2_3e67_d06a_07b83e437034["grandalf.layouts"]
  f966196c_7eac_1723_030f_5343072d2057 --> 62e8f597_e2c2_3e67_d06a_07b83e437034
  0b5e44b4_813d_b6b3_a0c4_7f59067d6d86["grandalf.routing"]
  f966196c_7eac_1723_030f_5343072d2057 --> 0b5e44b4_813d_b6b3_a0c4_7f59067d6d86
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  f966196c_7eac_1723_030f_5343072d2057 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  8551c22a_c7c2_547e_0f94_77eab59053b3["langchain_core.runnables.graph"]
  f966196c_7eac_1723_030f_5343072d2057 --> 8551c22a_c7c2_547e_0f94_77eab59053b3
  style f966196c_7eac_1723_030f_5343072d2057 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Draws DAG in ASCII.

Adapted from https://github.com/iterative/dvc/blob/main/dvc/dagascii.py.
"""

from __future__ import annotations

import math
import os
from typing import TYPE_CHECKING, Any

try:
    from grandalf.graphs import Edge, Graph, Vertex  # type: ignore[import-untyped]
    from grandalf.layouts import SugiyamaLayout  # type: ignore[import-untyped]
    from grandalf.routing import route_with_lines  # type: ignore[import-untyped]

    _HAS_GRANDALF = True
except ImportError:
    _HAS_GRANDALF = False

if TYPE_CHECKING:
    from collections.abc import Mapping, Sequence

    from langchain_core.runnables.graph import Edge as LangEdge


class VertexViewer:
    """VertexViewer class.

    Class to define vertex box boundaries that will be accounted for during
    graph building by grandalf.
    """

    HEIGHT = 3  # top and bottom box edges + text
    """Height of the box."""

    def __init__(self, name: str) -> None:
        """Create a VertexViewer.

        Args:
            name: name of the vertex.
        """
        self._h = self.HEIGHT  # top and bottom box edges + text
        self._w = len(name) + 2  # right and left bottom edges + text

    @property
    def h(self) -> int:
        """Height of the box."""
        return self._h

    @property
    def w(self) -> int:
        """Width of the box."""
        return self._w


class AsciiCanvas:
    """Class for drawing in ASCII."""

    TIMEOUT = 10
// ... (307 more lines)

Subdomains

Dependencies

  • collections.abc
  • grandalf.graphs
  • grandalf.layouts
  • grandalf.routing
  • langchain_core.runnables.graph
  • math
  • os
  • typing

Frequently Asked Questions

What does graph_ascii.py do?
graph_ascii.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in graph_ascii.py?
graph_ascii.py defines 5 function(s): _HAS_GRANDALF, _build_sugiyama_layout, collections, draw_ascii, grandalf.
What does graph_ascii.py depend on?
graph_ascii.py imports 8 module(s): collections.abc, grandalf.graphs, grandalf.layouts, grandalf.routing, langchain_core.runnables.graph, math, os, typing.
Where is graph_ascii.py in the architecture?
graph_ascii.py is located at libs/core/langchain_core/runnables/graph_ascii.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/core/langchain_core/runnables).

Analyze Your Own Codebase

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

Try Supermodel Free