GPTCache icon indicating copy to clipboard operation
GPTCache copied to clipboard

Semantic Cache is not working

Open awais-nayyar opened this issue 5 months ago • 2 comments

I am utilizing the GPT Semantic Cache as outlined in the Langchain documentation, combined with the Groq API and the Llama3-70b-8192 model. However, I'm encountering an issue where the semantic cache returns the same response repeatedly, even when different questions are asked. Can anybody know what could be the possible cause? Here is the code:

import hashlib

from gptcache import Cache from gptcache.adapter.api import init_similar_cache from langchain.cache import GPTCache from langchain_core.globals import set_llm_cache

def get_hashed_name(name): return hashlib.sha256(name.encode()).hexdigest()

def init_gptcache(cache_obj: Cache, llm: str): hashed_llm = get_hashed_name(llm) init_similar_cache(cache_obj=cache_obj, data_dir=f"similar_cache_{hashed_llm}")

set_llm_cache(GPTCache(init_gptcache))

awais-nayyar avatar Sep 16 '24 14:09 awais-nayyar