Skip to content

[Feature]: ByLLM - ReAct on Error #5515

@amadolid

Description

@amadolid

Feature Description

Since LLM can hallucinate on arguments for the tool, ValidationError is raised and stop the loop when arguments are not aligned with the signature.

Common llm react pattern will use the error as feedback to correct itself

Supporting "react on error" will help the LLM to have some feedback/reference on how it can correct itself and retry the call

Examples & References

Example Tool

def add_income(name: str, amount: float, frequency: str = "monthly", additional_name: str = "") -> str

LLM sometimes hallucinate even tho you have tool signature that amount is float and not nullable

File "/home/njanaijesinghe/pn_birdie_v2/venv/lib/python3.12/site-packages/byllm/types.py", line 169, in parse_arguments
    args[arg_name] = TypeAdapter(arg_type).validate_python(arg_json)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/njanaijesinghe/pn_birdie_v2/venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 441, in validate_python
    return self.validator.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for float
  Input should be a valid number [type=float_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.12/v/float_type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions