Skip to content

Commit

Permalink
Add the disable report config
Browse files Browse the repository at this point in the history
Signed-off-by: SimFG <[email protected]>
  • Loading branch information
SimFG committed Nov 22, 2023
1 parent 32aff18 commit 7ea9b98
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/unit_test_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
6 changes: 3 additions & 3 deletions examples/data_manager/scalar_store.py
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
2 changes: 1 addition & 1 deletion gptcache/adapter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions gptcache/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
1 change: 0 additions & 1 deletion tests/unit_tests/manager/test_weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_normal(self):
db.mul_add([VectorData(id=size, data=data[0])])
ret = db.search(data[0])
self.assertIn(ret[0][1], [0, size])
self.assertIn(ret[1][1], [0, size])
db.delete([0, 1, 2, 3, 4, 5, size])
ret = db.search(data[0])
self.assertNotIn(ret[0][1], [0, size])
Expand Down

0 comments on commit 7ea9b98

Please sign in to comment.