|
8 | 8 | from azure.identity import get_bearer_token_provider |
9 | 9 | from pathlib import Path |
10 | 10 | from datetime import datetime |
11 | | -from azure.ai.evaluation import GroundednessEvaluator |
| 11 | +from azure.ai.evaluation import GroundednessEvaluator, TaskAdherenceEvaluator |
12 | 12 | from pylint.lint import Run |
13 | 13 |
|
14 | 14 | token_provider = get_bearer_token_provider( |
@@ -229,9 +229,12 @@ def evaluate_fixes(file_path, original_content, fixed_content): |
229 | 229 |
|
230 | 230 | # Use the evaluate function with the JSONL file |
231 | 231 | eval = GroundednessEvaluator(model_config=model_config) |
| 232 | + adehere = TaskAdherenceEvaluator(model_config=model_config, threshold=3) |
| 233 | + |
232 | 234 |
|
233 | 235 | evaluation_result = eval(context=FILE_PROMPT + f"Fix pylint issues in this code:\n\n{original_content}", response=fixed_content) |
234 | | - EVAL_RESULTS[pylint_name] = evaluation_result |
| 236 | + adherence_result = adehere(query=FILE_PROMPT + f"Fix pylint issues in this code:\n\n{original_content}", response=fixed_content) |
| 237 | + EVAL_RESULTS[pylint_name] = evaluation_result , adherence_result |
235 | 238 |
|
236 | 239 | # Example usage |
237 | 240 | if __name__ == "__main__": |
@@ -278,8 +281,9 @@ def evaluate_fixes(file_path, original_content, fixed_content): |
278 | 281 | if key in EVAL_RESULTS: |
279 | 282 | f.write(f"Evaluation Results for {key}:") |
280 | 283 | f.write("\n") |
281 | | - f.write(f"Groundedness Score: {EVAL_RESULTS[key]}") |
| 284 | + f.write(f"Evaluation Score: {EVAL_RESULTS[key][0]}") |
282 | 285 | f.write("\n") |
| 286 | + f.write(f"Evaluation Score: {EVAL_RESULTS[key][1]}") |
283 | 287 | f.write("\n") |
284 | 288 | f.write("-----"*80) |
285 | 289 | f.write("\n") |
|
0 commit comments