Skip to content

Fix: Enhance robustness and clarity in kg-solver components #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thesteganos
Copy link

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant