fabricatio_improve.capabilities.correct

A module containing the Correct capability for reviewing, validating, and improving objects.

Classes

Correct

A class that provides the capability to correct objects.

Module Contents

class fabricatio_improve.capabilities.correct.Correct(/, **data: Any)

Bases: fabricatio_capabilities.capabilities.rating.Rating, abc.ABC

A class that provides the capability to correct objects.

async decide_solution(problem_solutions: fabricatio_improve.models.problem.ProblemSolutions, **kwargs: Unpack[fabricatio_capabilities.models.kwargs_types.BestKwargs]) fabricatio_improve.models.problem.ProblemSolutions

Decide the best solution from a list of problem solutions.

Parameters:
  • problem_solutions (ProblemSolutions) – The problem solutions to evaluate.

  • **kwargs (Unpack[BestKwargs]) – Additional keyword arguments for the decision process.

Returns:

The problem solutions with the best solution selected.

Return type:

ProblemSolutions

async decide_improvement(improvement: fabricatio_improve.models.improve.Improvement, **kwargs: Unpack[fabricatio_capabilities.models.kwargs_types.BestKwargs]) fabricatio_improve.models.improve.Improvement

Decide the best solution for each problem solution in an improvement.

Parameters:
  • improvement (Improvement) – The improvement containing problem solutions to evaluate.

  • **kwargs (Unpack[BestKwargs]) – Additional keyword arguments for the decision process.

Returns:

The improvement with the best solutions selected for each problem solution.

Return type:

Improvement

async fix_troubled_obj[M: fabricatio_core.models.generic.SketchedAble](obj: M, problem_solutions: fabricatio_improve.models.problem.ProblemSolutions, reference: str = '', **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[M]]) M | None

Fix a troubled object based on problem solutions.

Parameters:
  • obj (M) – The object to be fixed.

  • problem_solutions (ProblemSolutions) – The problem solutions to apply.

  • reference (str) – A reference or contextual information for the object.

  • **kwargs (Unpack[ValidateKwargs[M]]) – Additional keyword arguments for the validation process.

Returns:

The fixed object, or None if fixing fails.

Return type:

Optional[M]

async fix_troubled_string(input_text: str, problem_solutions: fabricatio_improve.models.problem.ProblemSolutions, reference: str = '', **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[str]]) str | None

Fix a troubled string based on problem solutions.

Parameters:
  • input_text (str) – The string to be fixed.

  • problem_solutions (ProblemSolutions) – The problem solutions to apply.

  • reference (str) – A reference or contextual information for the string.

  • **kwargs (Unpack[ValidateKwargs[str]]) – Additional keyword arguments for the validation process.

Returns:

The fixed string, or None if fixing fails.

Return type:

Optional[str]

async correct_obj[M: fabricatio_core.models.generic.SketchedAble](obj: M, improvement: fabricatio_improve.models.improve.Improvement, reference: str = '', **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[M]]) M | None

Review and correct an object based on defined criteria and templates.

This method first conducts a review of the given object, then uses the review results to generate a corrected version of the object using appropriate templates.

Parameters:
  • obj (M) – The object to be reviewed and corrected. Must implement ProposedAble.

  • improvement (Improvement) – The improvement object containing the review results.

  • reference (str) – A reference or contextual information for the object.

  • **kwargs (Unpack[ValidateKwargs[M]]) – Review configuration parameters including criteria and review options.

Returns:

A corrected version of the input object, or None if correction fails.

Return type:

Optional[M]

Raises:

TypeError – If the provided object doesn’t implement Display or WithBriefing interfaces.

async correct_string(input_text: str, improvement: fabricatio_improve.models.improve.Improvement, reference: str = '', **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[str]]) str | None

Review and correct a string based on defined criteria and templates.

This method first conducts a review of the given string, then uses the review results to generate a corrected version of the string using appropriate templates.

Parameters:
  • input_text (str) – The string to be reviewed and corrected.

  • improvement (Improvement) – The improvement object containing the review results.

  • reference (str) – A reference or contextual information for the string.

  • **kwargs (Unpack[ValidateKwargs[str]]) – Review configuration parameters including criteria and review options.

Returns:

A corrected version of the input string, or None if correction fails.

Return type:

Optional[str]

async correct_obj_inplace[M: fabricatio_capabilities.models.generic.ProposedUpdateAble](obj: M, **kwargs: Unpack[fabricatio_improve.models.kwargs_types.CorrectKwargs[M]]) M | None

Correct an object in place based on defined criteria and templates.

Parameters:
  • obj (M) – The object to be corrected.

  • **kwargs (Unpack[CorrectKwargs[M]]) – Additional keyword arguments for the correction process.

Returns:

The corrected object, or None if correction fails.

Return type:

Optional[M]