-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(testset generation) : Improvements (#195)
- Loading branch information
1 parent
462247b
commit 2d42d69
Showing
5 changed files
with
57 additions
and
16 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pytest | ||
pytest-xdist[psutil] | ||
llama_index |
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,31 @@ | ||
import json | ||
import re | ||
import warnings | ||
|
||
|
||
def load_as_json(text): | ||
""" | ||
validate and return given text as json | ||
""" | ||
|
||
try: | ||
return json.loads(text) | ||
except ValueError: | ||
warnings.warn("Invalid json") | ||
|
||
return {} | ||
|
||
|
||
def load_as_score(text): | ||
""" | ||
validate and returns given text as score | ||
""" | ||
|
||
pattern = r"^[\d.]+$" | ||
if not re.match(pattern, text): | ||
warnings.warn("Invalid score") | ||
score = 0.0 | ||
else: | ||
score = eval(text) | ||
|
||
return score |
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,4 +1,6 @@ | ||
def test_import(): | ||
import ragas | ||
from ragas.testset.testset_generator import TestsetGenerator | ||
|
||
assert TestsetGenerator is not None | ||
assert ragas is not None |