Home / Function/ _get_key() — langchain Function Reference

_get_key() — langchain Function Reference

Architecture documentation for the _get_key() function in string_run_evaluator.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  299b611e_fb70_d4ca_6dcc_c6031a8162d9["_get_key()"]
  3ac90b6f_675b_ff6a_04b3_989d183b1348["ChainStringRunMapper"]
  299b611e_fb70_d4ca_6dcc_c6031a8162d9 -->|defined in| 3ac90b6f_675b_ff6a_04b3_989d183b1348
  b8c4bf91_87d7_ce69_1350_1bcdf1bccbbb["map()"]
  b8c4bf91_87d7_ce69_1350_1bcdf1bccbbb -->|calls| 299b611e_fb70_d4ca_6dcc_c6031a8162d9
  style 299b611e_fb70_d4ca_6dcc_c6031a8162d9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py lines 168–177

    def _get_key(self, source: dict, key: str | None, which: str) -> str:
        if key is not None:
            return source[key]
        if len(source) == 1:
            return next(iter(source.values()))
        msg = (
            f"Could not map run {which} with multiple keys: "
            f"{source}\nPlease manually specify a {which}_key"
        )
        raise ValueError(msg)

Domain

Subdomains

Called By

Frequently Asked Questions

What does _get_key() do?
_get_key() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py.
Where is _get_key() defined?
_get_key() is defined in libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py at line 168.
What calls _get_key()?
_get_key() is called by 1 function(s): map.

Analyze Your Own Codebase

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

Try Supermodel Free