KAG
KAG copied to clipboard
Fix: Enhance robustness and clarity in kg-solver components
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:
-
KAGIterativePlanner:
- Corrected
is_static()method to returnFalse, aligning with its iterative behavior.
- Corrected
-
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.
- Removed a misleading note about an f-string formatting error from the
-
KAGStaticPlanner:
- Improved
finish_judgererror handling: If the LLM call to judge the answer fails, it now logs a warning and returnsFalse(treating the answer as potentially bad) instead of defaulting toTrue.
- Improved
-
ChunkRetrievedExecutor:
- Clarified schema name: Changed the
namefield in its schema dictionary from "Retriever" to "ChunkRetriever" to better differentiate it from other retriever executors likeKagHybridExecutor.
- Clarified schema name: Changed the
-
PyBasedMathExecutor:
- Added a configurable timeout (defaulting to 5 seconds) to the
subprocess.run()call within therun_py_codefunction. This prevents indefinite hangs from long-running or stuck Python scripts generated by the LLM. Includes handling forsubprocess.TimeoutExpired.
- Added a configurable timeout (defaulting to 5 seconds) to the
-
DefaultStaticPlanningPrompt:
- Enhanced
parse_responsemethod: Implemented more robust JSON decoding and structural validation for the LLM-generated DAG plan. It now raises more descriptiveValueErrorexceptions, including details of the malformed data, whenKeyErrororTypeErroroccurs during task creation from the DAG, aiding in debugging.
- Enhanced