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

Method lookup

libs/core/langchain_core/caches.py:51–70  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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:

Callers 9

get_promptsFunction · 0.45
_generate_with_cacheMethod · 0.45
test_cache_is_emptyMethod · 0.45
test_update_cacheMethod · 0.45
test_clear_cacheMethod · 0.45
test_cache_missMethod · 0.45
test_cache_hitMethod · 0.45

Calls

no outgoing calls

Tested by 7

test_cache_is_emptyMethod · 0.36
test_update_cacheMethod · 0.36
test_clear_cacheMethod · 0.36
test_cache_missMethod · 0.36
test_cache_hitMethod · 0.36