Home / Function/ predict() — langchain Function Reference

predict() — langchain Function Reference

Architecture documentation for the predict() function in llm.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5f5923e3_49b2_3390_e650_ddc0b0cee750["predict()"]
  ccf50fe1_4990_cf19_1e2d_25efe83f53c5["LLMChain"]
  5f5923e3_49b2_3390_e650_ddc0b0cee750 -->|defined in| ccf50fe1_4990_cf19_1e2d_25efe83f53c5
  95ce3986_2fc8_46a4_8a43_66522857e81e["apredict()"]
  95ce3986_2fc8_46a4_8a43_66522857e81e -->|calls| 5f5923e3_49b2_3390_e650_ddc0b0cee750
  5d7f331a_8fce_916c_b587_03a361f46ca8["predict_and_parse()"]
  5d7f331a_8fce_916c_b587_03a361f46ca8 -->|calls| 5f5923e3_49b2_3390_e650_ddc0b0cee750
  style 5f5923e3_49b2_3390_e650_ddc0b0cee750 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/llm.py lines 300–315

    def predict(self, callbacks: Callbacks = None, **kwargs: Any) -> str:
        """Format prompt with kwargs and pass to LLM.

        Args:
            callbacks: Callbacks to pass to LLMChain
            **kwargs: Keys to pass to prompt template.

        Returns:
            Completion from LLM.

        Example:
            ```python
            completion = llm.predict(adjective="funny")
            ```
        """
        return self(kwargs, callbacks=callbacks)[self.output_key]

Subdomains

Frequently Asked Questions

What does predict() do?
predict() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/llm.py.
Where is predict() defined?
predict() is defined in libs/langchain/langchain_classic/chains/llm.py at line 300.
What calls predict()?
predict() is called by 2 function(s): apredict, predict_and_parse.

Analyze Your Own Codebase

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

Try Supermodel Free