You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Enhance robustness and clarity in kg-solver components (OpenSPG#548)
This commit addresses several issues identified during a code analysis, focusing on improving the robustness, error handling, and clarity of various components within the KAG solver.
The following changes have been made:
1. **KAGIterativePlanner**:
* Corrected `is_static()` method to return `False`, aligning with its iterative behavior.
2. **KAGRetrievedResponse**:
* Removed a misleading note about an f-string formatting error from the `to_string()` method's docstring, as the error was not present in the code.
3. **KAGStaticPlanner**:
* Improved `finish_judger` error handling: If the LLM call to judge the answer fails, it now logs a warning and returns `False` (treating the answer as potentially bad) instead of defaulting to `True`.
4. **ChunkRetrievedExecutor**:
* Clarified schema name: Changed the `name` field in its schema dictionary from "Retriever" to "ChunkRetriever" to better differentiate it from other retriever executors like `KagHybridExecutor`.
5. **PyBasedMathExecutor**:
* Added a configurable timeout (defaulting to 5 seconds) to the `subprocess.run()` call within the `run_py_code` function. This prevents indefinite hangs from long-running or stuck Python scripts generated by the LLM. Includes handling for `subprocess.TimeoutExpired`.
6. **DefaultStaticPlanningPrompt**:
* Enhanced `parse_response` method: Implemented more robust JSON decoding and structural validation for the LLM-generated DAG plan. It now raises more descriptive `ValueError` exceptions, including details of the malformed data, when `KeyError` or `TypeError` occurs during task creation from the DAG, aiding in debugging.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
raiseValueError(f"The core plan data (after handling potential 'output' key) is not a dictionary. Got type: {type(actual_dag_data)}. Data: {actual_dag_data}")
166
+
167
+
try:
168
+
returnTask.create_tasks_from_dag(actual_dag_data)
169
+
except (KeyError, TypeError) ase:
170
+
error_message= (
171
+
f"LLM response for static planning was malformed. Error: {e}. "
172
+
f"Each task in the DAG dictionary must define 'executor', 'arguments', and 'dependent_task_ids'. "
173
+
f"Problematic DAG data: {actual_dag_data}"
174
+
)
175
+
raiseValueError(error_message)
176
+
exceptExceptionase: # Catch any other unexpected errors from create_tasks_from_dag
177
+
error_message= (
178
+
f"An unexpected error occurred while creating tasks from DAG. Error: {e}. "
0 commit comments