generate_prompt() — langchain Function Reference
Architecture documentation for the generate_prompt() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD c73294e8_26c4_ecd0_fa53_ec6d0a9c6c56["generate_prompt()"] f5a29046_740d_1358_3615_8cc689b26ca9["BaseLanguageModel"] c73294e8_26c4_ecd0_fa53_ec6d0a9c6c56 -->|defined in| f5a29046_740d_1358_3615_8cc689b26ca9 style c73294e8_26c4_ecd0_fa53_ec6d0a9c6c56 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/language_models/base.py lines 207–248
def generate_prompt(
self,
prompts: list[PromptValue],
stop: list[str] | None = None,
callbacks: Callbacks = None,
**kwargs: Any,
) -> LLMResult:
"""Pass a sequence of prompts to the model and return model generations.
This method should make use of batched calls for models that expose a batched
API.
Use this method when you want to:
1. Take advantage of batched calls,
2. Need more output from the model than just the top generated value,
3. Are building chains that are agnostic to the underlying language model
type (e.g., pure text completion models vs chat models).
Args:
prompts: List of `PromptValue` objects.
A `PromptValue` is an object that can be converted to match the format
of any language model (string for pure text generation models and
`BaseMessage` objects for chat models).
stop: Stop words to use when generating.
Model output is cut off at the first occurrence of any of these
substrings.
callbacks: `Callbacks` to pass through.
Used for executing additional functionality, such as logging or
streaming, throughout generation.
**kwargs: Arbitrary additional keyword arguments.
These are usually passed to the model provider API call.
Returns:
An `LLMResult`, which contains a list of candidate `Generation` objects for
each input prompt and additional model provider-specific output.
"""
Domain
Subdomains
Source
Frequently Asked Questions
What does generate_prompt() do?
generate_prompt() is a function in the langchain codebase, defined in libs/core/langchain_core/language_models/base.py.
Where is generate_prompt() defined?
generate_prompt() is defined in libs/core/langchain_core/language_models/base.py at line 207.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free