Spaces:
Sleeping
Sleeping
| from typing import Dict | |
| import sys | |
| import os | |
| sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'config')) | |
| from config import config | |
| def should_continue_groundedness(state: Dict) -> str: | |
| """Decides if groundedness is sufficient or needs improvement.""" | |
| print("---------should_continue_groundedness---------") | |
| print("groundedness loop count: ", state['groundedness_loop_count']) | |
| if state['groundedness_score'] >= config.GROUNDEDNESS_THRESHOLD: | |
| print("Moving to precision") | |
| return "check_precision" | |
| else: | |
| if state["groundedness_loop_count"] > state['loop_max_iter']: | |
| return "max_iterations_reached" | |
| else: | |
| print(f"---------Groundedness Score Threshold Not met. Refining Response-----------") | |
| return "refine_response" | |
| def should_continue_precision(state: Dict) -> str: | |
| """Decides if precision is sufficient or needs improvement.""" | |
| print("---------should_continue_precision---------") | |
| print("precision loop count: ", state['precision_loop_count']) | |
| if state['precision_score'] >= config.PRECISION_THRESHOLD: | |
| return "pass" | |
| else: | |
| if state['precision_loop_count'] > state['loop_max_iter']: | |
| return "max_iterations_reached" | |
| else: | |
| print(f"---------Precision Score Threshold Not met. Refining Query-----------") | |
| return "refine_query" | |