Look up based on prompt and llm_string. A cache implementation is expected to generate a key from the 2-tuple of prompt and llm_string (e.g., by concatenating them with a delimiter). Args: prompt: a string representation of the prompt. In the
(self, prompt: str, llm_string: str)
| 49 | |
| 50 | @abstractmethod |
| 51 | def lookup(self, prompt: str, llm_string: str) -> Optional[RETURN_VAL_TYPE]: |
| 52 | """Look up based on prompt and llm_string. |
| 53 | |
| 54 | A cache implementation is expected to generate a key from the 2-tuple |
| 55 | of prompt and llm_string (e.g., by concatenating them with a delimiter). |
| 56 | |
| 57 | Args: |
| 58 | prompt: a string representation of the prompt. |
| 59 | In the case of a Chat model, the prompt is a non-trivial |
| 60 | serialization of the prompt into the language model. |
| 61 | llm_string: A string representation of the LLM configuration. |
| 62 | This is used to capture the invocation parameters of the LLM |
| 63 | (e.g., model name, temperature, stop tokens, max tokens, etc.). |
| 64 | These invocation parameters are serialized into a string |
| 65 | representation. |
| 66 | |
| 67 | Returns: |
| 68 | On a cache miss, return None. On a cache hit, return the cached value. |
| 69 | The cached value is a list of Generations (or subclasses). |
| 70 | """ |
| 71 | |
| 72 | @abstractmethod |
| 73 | def update(self, prompt: str, llm_string: str, return_val: RETURN_VAL_TYPE) -> None: |
no outgoing calls