) -> dict:        vals = [            f"{i}: Action=[{action.tool}] returned observation = [{observation}]"            for i, (action, observation) in enumerate(agent_trajectory)        ]        trajectory = "\n".join(vals)        response = self.chain.run(dict(trajectory=trajectory, input=input), **kwargs)        decision = response.split("\n")[-1].strip()        score = 1 if decision == "Y" else 0        return {"score": score, "value": decision, "reasoning": response}The example above will return a score of 1 if the language model predicts that any of the actions were unnecessary, and it returns a score of 0 if all of them were predicted to be necessary. It returns the string 'decision' as the 'value', and includes the rest of the generated text as 'reasoning' to let you audit the decision.You can call this evaluator to grade the intermediate steps of your agent's trajectory.evaluator = StepNecessityEvaluator()evaluator.evaluate_agent_trajectory(    prediction="The answer is pi",    input="What is today?",    agent_trajectory=[        (            AgentAction(tool="ask", tool_input="What is today?", log=""),            "tomorrow's yesterday",        ),        (            AgentAction(tool="check_tv", tool_input="Watch tv for half hour", log=""),            "bzzz",        ),    ],)    {'score': 1, 'value': 'Y', 'reasoning': 'Y'}PreviousTrajectory EvaluatorsNextAgent TrajectoryCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
Open In Colab
Open In Colab ->: ) -> dict:        vals = [            f"{i}: Action=[{action.tool}] returned observation = [{observation}]"            for i, (action, observation) in enumerate(agent_trajectory)        ]        trajectory = "\n".join(vals)        response = self.chain.run(dict(trajectory=trajectory, input=input), **kwargs)        decision = response.split("\n")[-1].strip()        score = 1 if decision == "Y" else 0        return {"score": score, "value": decision, "reasoning": response}The example above will return a score of 1 if the language model predicts that any of the actions were unnecessary, and it returns a score of 0 if all of them were predicted to be necessary. It returns the string 'decision' as the 'value', and includes the rest of the generated text as 'reasoning' to let you audit the decision.You can call this evaluator to grade the intermediate steps of your agent's trajectory.evaluator = StepNecessityEvaluator()evaluator.evaluate_agent_trajectory(    prediction="The answer is pi",    input="What is today?",    agent_trajectory=[        (            AgentAction(tool="ask", tool_input="What is today?", log=""),            "tomorrow's yesterday",        ),        (            AgentAction(tool="check_tv", tool_input="Watch tv for half hour", log=""),            "bzzz",        ),    ],)    {'score': 1, 'value': 'Y', 'reasoning': 'Y'}PreviousTrajectory EvaluatorsNextAgent TrajectoryCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.