Skip to content

Commit 2ed390c

Browse files
authored
fix: change to schema (#1780)
1 parent a51f1fb commit 2ed390c

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/ragas/dataset_schema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ def upload(self, base_url: str = RAGAS_API_URL, verbose: bool = True) -> str:
553553
class PromptAnnotation(BaseModel):
554554
prompt_input: t.Dict[str, t.Any]
555555
prompt_output: t.Dict[str, t.Any]
556-
is_accepted: bool
557556
edited_output: t.Optional[t.Dict[str, t.Any]] = None
558557

559558
def __getitem__(self, key):
@@ -808,6 +807,7 @@ def get_prompt_annotations(self) -> t.Dict[str, t.List[PromptAnnotation]]:
808807
"""
809808
prompt_annotations = defaultdict(list)
810809
for sample in self.samples:
811-
for prompt_name, prompt_annotation in sample.prompts.items():
812-
prompt_annotations[prompt_name].append(prompt_annotation)
810+
if sample.is_accepted:
811+
for prompt_name, prompt_annotation in sample.prompts.items():
812+
prompt_annotations[prompt_name].append(prompt_annotation)
813813
return prompt_annotations

src/ragas/metrics/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,6 @@ def _optimize_demonstration(
311311
input_examples, output_examples = [], []
312312
for i, prompt_annotation in enumerate(prompt_annotation_list):
313313
try:
314-
# skip if the prompt is not accepted
315-
if not prompt_annotation.is_accepted:
316-
continue
317314
input_examples.append(
318315
input_model.model_validate(prompt_annotation.prompt_input)
319316
)

src/ragas/optimizers/genetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def feedback_mutation(
377377
)
378378
improved_candidates = []
379379
dataset = dataset.filter(lambda x: x["is_accepted"])
380-
380+
sample_size = min(sample_size, len(dataset))
381381
exec = Executor(
382382
desc="Feedback Mutation",
383383
raise_exceptions=raise_exceptions,

0 commit comments

Comments
 (0)