Skip to content

Commit 05d35a0

Browse files
authored
feat: load from annotated testset (#1747)
1 parent de6da38 commit 05d35a0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ragas/testset/synthesizers/testset_schema.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,19 @@ def upload(self, base_url: str = RAGAS_API_URL, verbose: bool = True) -> str:
158158
if verbose:
159159
print(f"Testset uploaded! View at {testset_endpoint}")
160160
return testset_endpoint
161+
162+
@classmethod
163+
def from_annotated(cls, path: str) -> Testset:
164+
"""
165+
Loads a testset from an annotated JSON file from app.ragas.io.
166+
"""
167+
import json
168+
169+
with open(path, "r") as f:
170+
annotated_testset = json.load(f)
171+
172+
samples = []
173+
for sample in annotated_testset:
174+
if sample["approval_status"] == "approved":
175+
samples.append(TestsetSample(**sample))
176+
return cls(samples=samples)

0 commit comments

Comments
 (0)