get_sub_prompts() — langchain Function Reference
Architecture documentation for the get_sub_prompts() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 11f618dd_a369_1622_0130_0cc8a952e5cd["get_sub_prompts()"] 6bee45b2_b649_e251_1fdc_dcf49f8bb331["BaseOpenAI"] 11f618dd_a369_1622_0130_0cc8a952e5cd -->|defined in| 6bee45b2_b649_e251_1fdc_dcf49f8bb331 9a3f8476_ed23_4017_8e21_6ee0b6176365["_stream()"] 9a3f8476_ed23_4017_8e21_6ee0b6176365 -->|calls| 11f618dd_a369_1622_0130_0cc8a952e5cd 58b8669b_d421_b6e5_b179_03394129fd02["_astream()"] 58b8669b_d421_b6e5_b179_03394129fd02 -->|calls| 11f618dd_a369_1622_0130_0cc8a952e5cd f5892a19_915a_df0a_fbd3_f7a5a0993b64["_generate()"] f5892a19_915a_df0a_fbd3_f7a5a0993b64 -->|calls| 11f618dd_a369_1622_0130_0cc8a952e5cd 2d321de2_cda4_2af7_7550_f3f179b1dddb["_agenerate()"] 2d321de2_cda4_2af7_7550_f3f179b1dddb -->|calls| 11f618dd_a369_1622_0130_0cc8a952e5cd c14f7ea9_3fb1_6c9f_d4ed_47bad90dcea8["max_tokens_for_prompt()"] 11f618dd_a369_1622_0130_0cc8a952e5cd -->|calls| c14f7ea9_3fb1_6c9f_d4ed_47bad90dcea8 style 11f618dd_a369_1622_0130_0cc8a952e5cd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/langchain_openai/llms/base.py lines 572–589
def get_sub_prompts(
self,
params: dict[str, Any],
prompts: list[str],
stop: list[str] | None = None,
) -> list[list[str]]:
"""Get the sub prompts for llm call."""
if stop is not None:
params["stop"] = stop
if params["max_tokens"] == -1:
if len(prompts) != 1:
msg = "max_tokens set to -1 not supported for multiple inputs."
raise ValueError(msg)
params["max_tokens"] = self.max_tokens_for_prompt(prompts[0])
return [
prompts[i : i + self.batch_size]
for i in range(0, len(prompts), self.batch_size)
]
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does get_sub_prompts() do?
get_sub_prompts() is a function in the langchain codebase, defined in libs/partners/openai/langchain_openai/llms/base.py.
Where is get_sub_prompts() defined?
get_sub_prompts() is defined in libs/partners/openai/langchain_openai/llms/base.py at line 572.
What does get_sub_prompts() call?
get_sub_prompts() calls 1 function(s): max_tokens_for_prompt.
What calls get_sub_prompts()?
get_sub_prompts() is called by 4 function(s): _agenerate, _astream, _generate, _stream.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free