Home / Function/ _determine_prediction_key() — langchain Function Reference

_determine_prediction_key() — langchain Function Reference

Architecture documentation for the _determine_prediction_key() function in runner_utils.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  864467e0_81f5_be42_651b_98803cc85971["_determine_prediction_key()"]
  8253c602_7d0c_9195_a7e1_3e9b19304131["runner_utils.py"]
  864467e0_81f5_be42_651b_98803cc85971 -->|defined in| 8253c602_7d0c_9195_a7e1_3e9b19304131
  a089196b_8c1b_51e2_42d9_a8bd76f8a276["_get_keys()"]
  a089196b_8c1b_51e2_42d9_a8bd76f8a276 -->|calls| 864467e0_81f5_be42_651b_98803cc85971
  style 864467e0_81f5_be42_651b_98803cc85971 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/smith/evaluation/runner_utils.py lines 498–521

def _determine_prediction_key(
    config: smith_eval.RunEvalConfig,
    run_outputs: list[str] | None,
) -> str | None:
    prediction_key = None
    if config.prediction_key:
        prediction_key = config.prediction_key
        if run_outputs and prediction_key not in run_outputs:
            logger.warning(
                "Prediction key %s not in chain's specified output keys %s. "
                "Evaluation behavior may be undefined.",
                prediction_key,
                run_outputs,
            )
    elif run_outputs and len(run_outputs) == 1:
        prediction_key = run_outputs[0]
    elif run_outputs is not None and len(run_outputs) > 1:
        logger.warning(
            "Chain expects multiple output keys: %s,"
            " Evaluation behavior may be undefined. Specify a prediction_key"
            " in the RunEvalConfig to avoid this warning.",
            run_outputs,
        )
    return prediction_key

Domain

Subdomains

Called By

Frequently Asked Questions

What does _determine_prediction_key() do?
_determine_prediction_key() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py.
Where is _determine_prediction_key() defined?
_determine_prediction_key() is defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py at line 498.
What calls _determine_prediction_key()?
_determine_prediction_key() is called by 1 function(s): _get_keys.

Analyze Your Own Codebase

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

Try Supermodel Free