Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/â€‹OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsTrajectory EvaluatorsCustom Trajectory EvaluatorAgent TrajectoryExamplesDebuggingDeploymentLangSmithModel ComparisonEcosystemAdditional resourcesGuidesEvaluationTrajectory EvaluatorsCustom Trajectory EvaluatorCustom Trajectory EvaluatorYou can make your own custom trajectory evaluators by inheriting from the AgentTrajectoryEvaluator class and overwriting the _evaluate_agent_trajectory (and _aevaluate_agent_action) method.In this example, you will make a simple trajectory evaluator that uses an LLM to determine if any actions were unnecessary.from typing import Any, Optional, Sequence, Tuplefrom langchain.chat_models import ChatOpenAIfrom langchain.chains import LLMChainfrom langchain.schema import AgentActionfrom langchain.evaluation import AgentTrajectoryEvaluatorclass StepNecessityEvaluator(AgentTrajectoryEvaluator):    """Evaluate the perplexity of a predicted string."""    def __init__(self) -> None:        llm = ChatOpenAI(model="gpt-4", temperature=0.0)        template = """Are any of the following steps unnecessary in answering {input}? Provide the verdict on a new line as a single "Y" for yes or "N" for no.        DATA        ------        Steps: {trajectory}        ------        Verdict:"""        self.chain = LLMChain.from_string(llm, template)    def _evaluate_agent_trajectory(