Skip to content

Commit

Permalink
feat: load from annotated testset (#1747)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmachan authored Dec 10, 2024
1 parent de6da38 commit 05d35a0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/ragas/testset/synthesizers/testset_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,19 @@ def upload(self, base_url: str = RAGAS_API_URL, verbose: bool = True) -> str:
if verbose:
print(f"Testset uploaded! View at {testset_endpoint}")
return testset_endpoint

@classmethod
def from_annotated(cls, path: str) -> Testset:
"""
Loads a testset from an annotated JSON file from app.ragas.io.
"""
import json

with open(path, "r") as f:
annotated_testset = json.load(f)

samples = []
for sample in annotated_testset:
if sample["approval_status"] == "approved":
samples.append(TestsetSample(**sample))
return cls(samples=samples)

0 comments on commit 05d35a0

Please sign in to comment.