diff --git a/.github/workflows/unit_test_main.yaml b/.github/workflows/unit_test_main.yaml index e3d27d03..fee3eb01 100644 --- a/.github/workflows/unit_test_main.yaml +++ b/.github/workflows/unit_test_main.yaml @@ -93,21 +93,21 @@ jobs: export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python python3 -m pytest -k "not embedding and not processor" --cov=gptcache --cov-report xml:coverage.xml --cov-append ./tests/ - - name: Embedding Unit Tests + - name: Processor Unit Tests timeout-minutes: 30 shell: bash run: | export IS_CI=true export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python - python3 -m pytest --cov=gptcache --cov-report xml:coverage.xml --cov-append ./tests/unit_tests/embedding/ + python3 -m pytest --cov=gptcache --cov-append --cov-report xml:coverage.xml ./tests/unit_tests/processor/ - - name: Processor Unit Tests + - name: Embedding Unit Tests timeout-minutes: 30 shell: bash run: | export IS_CI=true export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python - python3 -m pytest --cov=gptcache --cov-append --cov-report xml:coverage.xml ./tests/unit_tests/processor/ + python3 -m pytest --cov=gptcache --cov-report xml:coverage.xml --cov-append ./tests/unit_tests/embedding/ - name: Upload coverage to Codecov uses: codecov/codecov-action@v3.1.0 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