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],
)
| 182 | |
| 183 | |
| 184 | def 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 | |
| 203 | async def aupdate_cache( |
no test coverage detected