Home / Function/ aprep_prompts() — langchain Function Reference

aprep_prompts() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  5fbfd29a_5361_2eb2_3d24_d46ae6a681e4["aprep_prompts()"]
  ccf50fe1_4990_cf19_1e2d_25efe83f53c5["LLMChain"]
  5fbfd29a_5361_2eb2_3d24_d46ae6a681e4 -->|defined in| ccf50fe1_4990_cf19_1e2d_25efe83f53c5
  926fd9b4_0102_a6de_8f35_2fe1bcf91155["agenerate()"]
  926fd9b4_0102_a6de_8f35_2fe1bcf91155 -->|calls| 5fbfd29a_5361_2eb2_3d24_d46ae6a681e4
  style 5fbfd29a_5361_2eb2_3d24_d46ae6a681e4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/llm.py lines 199–222

    async def aprep_prompts(
        self,
        input_list: list[dict[str, Any]],
        run_manager: AsyncCallbackManagerForChainRun | None = None,
    ) -> tuple[list[PromptValue], list[str] | None]:
        """Prepare prompts from inputs."""
        stop = None
        if len(input_list) == 0:
            return [], stop
        if "stop" in input_list[0]:
            stop = input_list[0]["stop"]
        prompts = []
        for inputs in input_list:
            selected_inputs = {k: inputs[k] for k in self.prompt.input_variables}
            prompt = self.prompt.format_prompt(**selected_inputs)
            _colored_text = get_colored_text(prompt.to_string(), "green")
            _text = "Prompt after formatting:\n" + _colored_text
            if run_manager:
                await run_manager.on_text(_text, end="\n", verbose=self.verbose)
            if "stop" in inputs and inputs["stop"] != stop:
                msg = "If `stop` is present in any inputs, should be present in all."
                raise ValueError(msg)
            prompts.append(prompt)
        return prompts, stop

Subdomains

Called By

Frequently Asked Questions

What does aprep_prompts() do?
aprep_prompts() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/llm.py.
Where is aprep_prompts() defined?
aprep_prompts() is defined in libs/langchain/langchain_classic/chains/llm.py at line 199.
What calls aprep_prompts()?
aprep_prompts() is called by 1 function(s): agenerate.

Analyze Your Own Codebase

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

Try Supermodel Free