MCPcopy
hub / github.com/langchain-ai/langchain / update_cache

Function update_cache

libs/core/langchain_core/language_models/llms.py:184–200  ·  view source on GitHub ↗

Update the cache and get the LLM output.

(
    cache: Union[BaseCache, bool, None],
    existing_prompts: Dict[int, List],
    llm_string: str,
    missing_prompt_idxs: List[int],
    new_results: LLMResult,
    prompts: List[str],
)

Source from the content-addressed store, hash-verified

182
183
184def update_cache(
185 cache: Union[BaseCache, bool, None],
186 existing_prompts: Dict[int, List],
187 llm_string: str,
188 missing_prompt_idxs: List[int],
189 new_results: LLMResult,
190 prompts: List[str],
191) -> Optional[dict]:
192 """Update the cache and get the LLM output."""
193 llm_cache = _resolve_cache(cache)
194 for i, result in enumerate(new_results.generations):
195 existing_prompts[missing_prompt_idxs[i]] = result
196 prompt = prompts[missing_prompt_idxs[i]]
197 if llm_cache is not None:
198 llm_cache.update(prompt, llm_string, result)
199 llm_output = new_results.llm_output
200 return llm_output
201
202
203async def aupdate_cache(

Callers 1

generateMethod · 0.85

Calls 2

_resolve_cacheFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected