Skip to content

fix: change to schema #1780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ragas/dataset_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ def upload(self, base_url: str = RAGAS_API_URL, verbose: bool = True) -> str:
class PromptAnnotation(BaseModel):
prompt_input: t.Dict[str, t.Any]
prompt_output: t.Dict[str, t.Any]
is_accepted: bool
edited_output: t.Optional[t.Dict[str, t.Any]] = None

def __getitem__(self, key):
Expand Down Expand Up @@ -808,6 +807,7 @@ def get_prompt_annotations(self) -> t.Dict[str, t.List[PromptAnnotation]]:
"""
prompt_annotations = defaultdict(list)
for sample in self.samples:
for prompt_name, prompt_annotation in sample.prompts.items():
prompt_annotations[prompt_name].append(prompt_annotation)
if sample.is_accepted:
for prompt_name, prompt_annotation in sample.prompts.items():
prompt_annotations[prompt_name].append(prompt_annotation)
return prompt_annotations
3 changes: 0 additions & 3 deletions src/ragas/metrics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,6 @@ def _optimize_demonstration(
input_examples, output_examples = [], []
for i, prompt_annotation in enumerate(prompt_annotation_list):
try:
# skip if the prompt is not accepted
if not prompt_annotation.is_accepted:
continue
input_examples.append(
input_model.model_validate(prompt_annotation.prompt_input)
)
Expand Down
2 changes: 1 addition & 1 deletion src/ragas/optimizers/genetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def feedback_mutation(
)
improved_candidates = []
dataset = dataset.filter(lambda x: x["is_accepted"])

sample_size = min(sample_size, len(dataset))
exec = Executor(
desc="Feedback Mutation",
raise_exceptions=raise_exceptions,
Expand Down
Loading