From efdd4b8b8e32fc26496b828981a306a0ee1efea5 Mon Sep 17 00:00:00 2001 From: magicyuan876 <317617749@qq.com> Date: Fri, 6 Dec 2024 15:23:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4kwargs=E4=B8=AD=E7=9A=84hashi?= =?UTF-8?q?ng=5Fkv=E5=8F=82=E6=95=B0=E5=8F=96=E4=B8=BA=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lightrag/llm.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lightrag/llm.py b/lightrag/llm.py index d147e416..09e9fd74 100644 --- a/lightrag/llm.py +++ b/lightrag/llm.py @@ -73,11 +73,12 @@ async def openai_complete_if_cache( messages.extend(history_messages) messages.append({"role": "user", "content": prompt}) + hashing_kv: BaseKVStorage = kwargs.pop("hashing_kv", None) # Handle cache mode = kwargs.pop("mode", "default") args_hash = compute_args_hash(model, messages) cached_response, quantized, min_val, max_val = await handle_cache( - kwargs.get("hashing_kv"), args_hash, prompt, mode + hashing_kv, args_hash, prompt, mode ) if cached_response is not None: return cached_response @@ -219,12 +220,12 @@ async def bedrock_complete_if_cache( # Add user prompt messages.append({"role": "user", "content": [{"text": prompt}]}) - + hashing_kv: BaseKVStorage = kwargs.pop("hashing_kv", None) # Handle cache mode = kwargs.pop("mode", "default") args_hash = compute_args_hash(model, messages) cached_response, quantized, min_val, max_val = await handle_cache( - kwargs.get("hashing_kv"), args_hash, prompt, mode + hashing_kv, args_hash, prompt, mode ) if cached_response is not None: return cached_response @@ -250,12 +251,12 @@ async def bedrock_complete_if_cache( args["inferenceConfig"][inference_params_map.get(param, param)] = ( kwargs.pop(param) ) - + hashing_kv: BaseKVStorage = kwargs.pop("hashing_kv", None) # Handle cache mode = kwargs.pop("mode", "default") args_hash = compute_args_hash(model, messages) cached_response, quantized, min_val, max_val = await handle_cache( - kwargs.get("hashing_kv"), args_hash, prompt, mode + hashing_kv, args_hash, prompt, mode ) if cached_response is not None: return cached_response