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

Function aupdate_cache

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

Update the cache and get the LLM output. Async version

(
    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

201
202
203async def aupdate_cache(
204 cache: Union[BaseCache, bool, None],
205 existing_prompts: Dict[int, List],
206 llm_string: str,
207 missing_prompt_idxs: List[int],
208 new_results: LLMResult,
209 prompts: List[str],
210) -> Optional[dict]:
211 """Update the cache and get the LLM output. Async version"""
212 llm_cache = _resolve_cache(cache)
213 for i, result in enumerate(new_results.generations):
214 existing_prompts[missing_prompt_idxs[i]] = result
215 prompt = prompts[missing_prompt_idxs[i]]
216 if llm_cache:
217 await llm_cache.aupdate(prompt, llm_string, result)
218 llm_output = new_results.llm_output
219 return llm_output
220
221
222class BaseLLM(BaseLanguageModel[str], ABC):

Callers 1

agenerateMethod · 0.85

Calls 2

_resolve_cacheFunction · 0.85
aupdateMethod · 0.45

Tested by

no test coverage detected