Spaces:
Runtime error
Runtime error
| import time | |
| import logging | |
| logging.basicConfig(level=logging.INFO) | |
| class SelfEvaluator: | |
| def __init__(self): | |
| self.evaluation_log = [] | |
| def evaluate(self, task_output: str): | |
| quality_score = self.heuristic_score(task_output) | |
| self.evaluation_log.append({ | |
| "output": task_output, | |
| "score": quality_score, | |
| "timestamp": time.time() | |
| }) | |
| logging.info(f"Self-evaluation completed: Score={quality_score}") | |
| return quality_score | |
| def heuristic_score(self, output: str): | |
| # Simple evaluation heuristic based on length and keyword presence | |
| if "error" in output.lower(): | |
| return 0.2 | |
| elif len(output) < 20: | |
| return 0.5 | |
| else: | |
| return 0.9 | |
| def get_log(self): | |
| return self.evaluation_log | |