Home / Function/ _evaluate_agent_trajectory() — langchain Function Reference

_evaluate_agent_trajectory() — langchain Function Reference

Architecture documentation for the _evaluate_agent_trajectory() function in trajectory_eval_chain.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  209b81c4_c8b0_b3f6_5d00_bbfecbd33b06["_evaluate_agent_trajectory()"]
  9066f65c_c5a3_1534_5336_72609f4ff02b["TrajectoryEvalChain"]
  209b81c4_c8b0_b3f6_5d00_bbfecbd33b06 -->|defined in| 9066f65c_c5a3_1534_5336_72609f4ff02b
  55207f35_65b3_64d0_f5f6_009c83675231["get_agent_trajectory()"]
  209b81c4_c8b0_b3f6_5d00_bbfecbd33b06 -->|calls| 55207f35_65b3_64d0_f5f6_009c83675231
  style 209b81c4_c8b0_b3f6_5d00_bbfecbd33b06 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/evaluation/agents/trajectory_eval_chain.py lines 329–372

    def _evaluate_agent_trajectory(
        self,
        *,
        prediction: str,
        input: str,
        agent_trajectory: Sequence[tuple[AgentAction, str]],
        reference: str | None = None,
        callbacks: Callbacks = None,
        tags: list[str] | None = None,
        metadata: dict[str, Any] | None = None,
        include_run_info: bool = False,
        **kwargs: Any,
    ) -> dict:
        """Evaluate a trajectory.

        Args:
            prediction: The final predicted response.
            input: The input to the agent.
            agent_trajectory: The intermediate steps forming the agent trajectory.
            reference: The reference answer.
            callbacks: Callbacks to use for this chain run.
            tags: The tags to apply.
            metadata: The metadata to use.
            include_run_info: Whether to include run info in the output.
            **kwargs: Additional keyword arguments.

        Returns:
            The evaluation result, which includes the score and optionally
                the reasoning for reaching that.
        """
        inputs = {
            "question": input,
            "agent_trajectory": self.get_agent_trajectory(agent_trajectory),
            "answer": prediction,
            "reference": reference,
        }
        return self.__call__(
            inputs=inputs,
            callbacks=callbacks,
            tags=tags,
            metadata=metadata,
            include_run_info=include_run_info,
            return_only_outputs=True,
        )

Domain

Subdomains

Frequently Asked Questions

What does _evaluate_agent_trajectory() do?
_evaluate_agent_trajectory() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/agents/trajectory_eval_chain.py.
Where is _evaluate_agent_trajectory() defined?
_evaluate_agent_trajectory() is defined in libs/langchain/langchain_classic/evaluation/agents/trajectory_eval_chain.py at line 329.
What does _evaluate_agent_trajectory() call?
_evaluate_agent_trajectory() calls 1 function(s): get_agent_trajectory.

Analyze Your Own Codebase

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

Try Supermodel Free