prep_prompts() — langchain Function Reference
Architecture documentation for the prep_prompts() function in llm.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ac9c4aef_a496_a26f_96a9_e9cc5be4c22d["prep_prompts()"] ccf50fe1_4990_cf19_1e2d_25efe83f53c5["LLMChain"] ac9c4aef_a496_a26f_96a9_e9cc5be4c22d -->|defined in| ccf50fe1_4990_cf19_1e2d_25efe83f53c5 377cb47d_aeea_738a_00c1_527af33d920e["generate()"] 377cb47d_aeea_738a_00c1_527af33d920e -->|calls| ac9c4aef_a496_a26f_96a9_e9cc5be4c22d style ac9c4aef_a496_a26f_96a9_e9cc5be4c22d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/llm.py lines 174–197
def prep_prompts(
self,
input_list: list[dict[str, Any]],
run_manager: CallbackManagerForChainRun | 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:
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
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does prep_prompts() do?
prep_prompts() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/llm.py.
Where is prep_prompts() defined?
prep_prompts() is defined in libs/langchain/langchain_classic/chains/llm.py at line 174.
What calls prep_prompts()?
prep_prompts() is called by 1 function(s): generate.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free