-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from confident-ai/feature/add-chatbot-tset
add chatbot test
- Loading branch information
Showing
6 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Run pytest in matrix | ||
|
||
on: push | ||
|
||
jobs: | ||
examples: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
# cache: "pip" | ||
|
||
# - name: Get pip cache dir | ||
# id: pip-cache | ||
# run: echo "::set-output name=dir::$(pip cache dir)" | ||
|
||
- name: Cache dependencies | ||
id: cache-dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: dependencies-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} | ||
restore-keys: | | ||
dependencies-${{ matrix.python-version }}- | ||
dependencies- | ||
- name: Install dependencies | ||
env: | ||
python-version: ${{ matrix.python-version }} | ||
run: | | ||
python -c "import sys; print(sys.version)" | ||
python -m pip install --upgrade pip | ||
python -m pip install -r requirements.txt ragas | ||
python -m pip install . pytest-rerunfailures pytest-asyncio | ||
- name: Run Unit Tests (pytest) | ||
env: | ||
python-version: ${{ matrix.python-version }} | ||
run: | | ||
deepeval test run -x tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__: str = "0.17.2" | ||
__version__: str = "0.17.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
from deepeval.metrics.factual_consistency import FactualConsistencyMetric | ||
from deepeval.test_case import LLMTestCase | ||
from deepeval.run_test import assert_test | ||
|
||
|
||
def test_1(): | ||
input = "What does your company do?" | ||
output = "My company doesn't do anything." | ||
context = "Our company specializes in cloud computing, data analytics, and machine learning. We offer a range of services including cloud storage solutions, data analytics platforms, and custom machine learning models." | ||
factual_consistency_metric = FactualConsistencyMetric(minimum_score=1.0) | ||
test_case = LLMTestCase(output=output, context=context) | ||
with pytest.raises(AssertionError): | ||
assert_test(test_case, [factual_consistency_metric]) | ||
|
||
|
||
def test_2(): | ||
input = "What does your company do?" | ||
output = "My company is a cloud computing company." | ||
context = "Our company specializes in cloud computing, data analytics, and machine learning. We offer a range of services including cloud storage solutions, data analytics platforms, and custom machine learning models." | ||
factual_consistency_metric = FactualConsistencyMetric(minimum_score=0.5) | ||
test_case = LLMTestCase(output=output, context=context) | ||
assert_test(test_case, [factual_consistency_metric]) |