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],
)
| 201 | |
| 202 | |
| 203 | async 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 | |
| 222 | class BaseLLM(BaseLanguageModel[str], ABC): |
no test coverage detected