nat.plugins.langchain.eval.langsmith_custom_evaluator#
Attributes#
Classes#
Import any LangSmith-compatible evaluator by Python dotted path. |
Functions#
|
Import an evaluator from a Python dotted path. |
|
Auto-detect which LangSmith evaluator convention is being used. |
|
Register a custom LangSmith evaluator with NAT. |
Module Contents#
- logger#
- _import_evaluator(dotted_path: str) Any#
Import an evaluator from a Python dotted path.
Supports both module-level callables and class references: -
'my_package.evaluators.my_function'-> imports and returns the function -'my_package.evaluators.MyClass'-> imports and instantiates the class- Args:
dotted_path: Full Python dotted path to the evaluator.
- Returns:
The imported evaluator (callable or instance).
- Raises:
ImportError: If the module cannot be imported. AttributeError: If the attribute cannot be found in the module.
- _detect_convention(evaluator: Any) str#
Auto-detect which LangSmith evaluator convention is being used.
Inspects the evaluator to determine if it’s a RunEvaluator subclass, a function with
(run, example)signature, or a function with(inputs, outputs, reference_outputs)signature.- Args:
evaluator: The evaluator callable or instance.
- Returns:
One of
'run_evaluator_class','run_example_function', or'openevals_function'.
- class LangSmithCustomEvaluatorConfig#
Bases:
nat.data_models.evaluator.EvaluatorBaseConfig,nat.plugins.langchain.eval.langsmith_evaluator.LangSmithExtraFieldsMixinImport any LangSmith-compatible evaluator by Python dotted path.
Supports RunEvaluator subclasses,
(run, example)functions, and(inputs, outputs, reference_outputs)functions. The calling convention is auto-detected at registration time.For built-in openevals evaluators, prefer
_type: langsmithwith a short name instead.
- async register_langsmith_custom_evaluator(
- config: LangSmithCustomEvaluatorConfig,
- builder: nat.builder.builder.EvalBuilder,
Register a custom LangSmith evaluator with NAT.