(self, node: Node)
| 301 | return overlap / total_words > 0.7 |
| 302 | |
| 303 | def evaluate(self, node: Node) -> float: |
| 304 | # Extract the final answer from the node's state |
| 305 | answer, confidence = self.extract_answer(node.state) |
| 306 | |
| 307 | # Check if the answer is a number |
| 308 | try: |
| 309 | float(answer) |
| 310 | logger.debug(f"Evaluated node. Answer: {answer}, Confidence: {confidence}, Value: {confidence}") |
| 311 | return confidence # Return the confidence as the value |
| 312 | except ValueError: |
| 313 | logger.debug(f"Evaluated node. Answer: {answer}, Confidence: {confidence}, Value: 0.0") |
| 314 | return 0.0 # If it's not a valid number, return a low score |
| 315 | |
| 316 | def extract_answer(self, final_state: str) -> Tuple[str, float]: |
| 317 | logger.debug(f"Extracting answer from state: {final_state}") |
no test coverage detected