From fd026b8e03e126a700e061c74f533eefea0a8ee0 Mon Sep 17 00:00:00 2001 From: SimFG Date: Wed, 1 Nov 2023 15:32:25 +0800 Subject: [PATCH] Add the disable report config Signed-off-by: SimFG --- examples/data_manager/scalar_store.py | 6 +++--- gptcache/adapter/adapter.py | 2 +- gptcache/config.py | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/data_manager/scalar_store.py b/examples/data_manager/scalar_store.py index 01a20fda..c07a7ee6 100644 --- a/examples/data_manager/scalar_store.py +++ b/examples/data_manager/scalar_store.py @@ -1,15 +1,15 @@ import os + import numpy as np -from gptcache.adapter import openai from gptcache import cache +from gptcache.adapter import openai from gptcache.manager import get_data_manager, CacheBase, VectorBase from gptcache.similarity_evaluation.distance import SearchDistanceEvaluation - d = 8 - +# Change the embdding function to your own def mock_embeddings(data, **kwargs): return np.random.random((d, )).astype('float32') diff --git a/gptcache/adapter/adapter.py b/gptcache/adapter/adapter.py index 2121bd70..aaa279ea 100644 --- a/gptcache/adapter/adapter.py +++ b/gptcache/adapter/adapter.py @@ -206,7 +206,7 @@ def post_process(): chat_cache.data_manager.add_session( cache_whole_data[2], session.name, pre_embedding_data ) - if cache_whole_data: + if cache_whole_data and not chat_cache.config.disable_report: # user_question / cache_question / cache_question_id / cache_answer / similarity / consume time/ time report_cache_data = cache_whole_data[3] report_search_data = cache_whole_data[2] diff --git a/gptcache/config.py b/gptcache/config.py index aad2ef18..2c8fd2ad 100644 --- a/gptcache/config.py +++ b/gptcache/config.py @@ -46,6 +46,7 @@ def __init__( context_len: Optional[int] = None, skip_list: List[str] = None, data_check: bool = False, + disable_report: bool = False, ): if similarity_threshold < 0 or similarity_threshold > 1: raise CacheError( @@ -63,3 +64,4 @@ def __init__( skip_list = ["system", "assistant"] self.skip_list = skip_list self.data_check = data_check + self.disable_report = disable_report