Home / Function/ compare() — langchain Function Reference

compare() — langchain Function Reference

Architecture documentation for the compare() function in model_laboratory.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  9d725907_3c29_8573_eb15_52e400e4ca4b["compare()"]
  ddc55513_8bea_9f0f_9a07_33c17a0d376f["ModelLaboratory"]
  9d725907_3c29_8573_eb15_52e400e4ca4b -->|defined in| ddc55513_8bea_9f0f_9a07_33c17a0d376f
  style 9d725907_3c29_8573_eb15_52e400e4ca4b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/model_laboratory.py lines 83–98

    def compare(self, text: str) -> None:
        """Compare model outputs on an input text.

        If a prompt was provided with starting the laboratory, then this text will be
        fed into the prompt. If no prompt was provided, then the input text is the
        entire prompt.

        Args:
            text: input text to run all models on.
        """
        print(f"\033[1mInput:\033[0m\n{text}\n")  # noqa: T201
        for i, chain in enumerate(self.chains):
            name = self.names[i] if self.names is not None else str(chain)
            print_text(name, end="\n")
            output = chain.run(text)
            print_text(output, color=self.chain_colors[str(i)], end="\n\n")

Domain

Subdomains

Frequently Asked Questions

What does compare() do?
compare() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/model_laboratory.py.
Where is compare() defined?
compare() is defined in libs/langchain/langchain_classic/model_laboratory.py at line 83.

Analyze Your Own Codebase

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

Try Supermodel Free