Home / Function/ invoke() — langchain Function Reference

invoke() — langchain Function Reference

Architecture documentation for the invoke() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  cb452c76_8a94_ba42_0e22_9ad2f706a15f["invoke()"]
  dddce6a3_2420_c71d_01fe_f214c3eb2503["BasePromptTemplate"]
  cb452c76_8a94_ba42_0e22_9ad2f706a15f -->|defined in| dddce6a3_2420_c71d_01fe_f214c3eb2503
  style cb452c76_8a94_ba42_0e22_9ad2f706a15f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/prompts/base.py lines 206–229

    def invoke(
        self, input: dict, config: RunnableConfig | None = None, **kwargs: Any
    ) -> PromptValue:
        """Invoke the prompt.

        Args:
            input: Input to the prompt.
            config: Configuration for the prompt.

        Returns:
            The output of the prompt.
        """
        config = ensure_config(config)
        if self.metadata:
            config["metadata"] = {**config["metadata"], **self.metadata}
        if self.tags:
            config["tags"] += self.tags
        return self._call_with_config(
            self._format_prompt_with_error_handling,
            input,
            config,
            run_type="prompt",
            serialized=self._serialized,
        )

Subdomains

Frequently Asked Questions

What does invoke() do?
invoke() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/base.py.
Where is invoke() defined?
invoke() is defined in libs/core/langchain_core/prompts/base.py at line 206.

Analyze Your Own Codebase

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

Try Supermodel Free