fabricatio_improve.capabilities.review

A module that provides functionality to rate tasks based on a rating manual and score range.

Classes

Review

Class that provides functionality to review tasks and strings using a language model.

Module Contents

class fabricatio_improve.capabilities.review.Review(/, **data: Any)

Bases: fabricatio_capabilities.capabilities.rating.Rating, fabricatio_core.capabilities.propose.Propose, abc.ABC

Class that provides functionality to review tasks and strings using a language model.

This class extends GiveRating and Propose capabilities to analyze content, identify problems, and suggest solutions based on specified criteria.

The review process can be applied to Task objects or plain strings with appropriate topic and criteria.

async review_task[T](task: fabricatio_core.models.task.Task[T], **kwargs: Unpack[fabricatio_improve.models.kwargs_types.ReviewKwargs[fabricatio_improve.models.improve.Improvement]]) fabricatio_improve.models.improve.Improvement | None

Review a task using specified review criteria.

This method analyzes a task object to identify problems and propose solutions based on the criteria provided in kwargs.

Parameters:
  • task (Task[T]) – The task object to be reviewed.

  • **kwargs (Unpack[ReviewKwargs]) – Additional keyword arguments for the review process, including topic and optional criteria.

Returns:

A review result containing identified problems and proposed solutions,

with a reference to the original task.

Return type:

Improvement[Task[T]]

async review_string(input_text: str, topic: str, criteria: Set[str] | None = None, rating_manual: Dict[str, str] | None = None, **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[fabricatio_improve.models.improve.Improvement]]) fabricatio_improve.models.improve.Improvement | None

Review a string based on specified topic and criteria.

This method analyzes a text string to identify problems and propose solutions based on the given topic and criteria.

Parameters:
  • input_text (str) – The text content to be reviewed.

  • topic (str) – The subject topic for the review criteria.

  • criteria (Optional[Set[str]], optional) – A set of criteria for the review. If not provided, criteria will be drafted automatically. Defaults to None.

  • rating_manual (Optional[Dict[str,str]], optional) – A dictionary of rating criteria and their corresponding scores.

  • **kwargs (Unpack[ValidateKwargs]) – Additional keyword arguments for the LLM usage.

Returns:

A review result containing identified problems and proposed solutions,

with a reference to the original text.

Return type:

Improvement

async review_obj[M: (fabricatio_core.models.generic.Display, fabricatio_core.models.generic.WithBriefing)](obj: M, **kwargs: Unpack[fabricatio_improve.models.kwargs_types.ReviewKwargs[fabricatio_improve.models.improve.Improvement]]) fabricatio_improve.models.improve.Improvement | None

Review an object that implements Display or WithBriefing interface.

This method extracts displayable text from the object and performs a review based on the criteria provided in kwargs.

Parameters:
  • obj (M) – The object to be reviewed, which must implement either Display or WithBriefing.

  • **kwargs (Unpack[ReviewKwargs]) – Additional keyword arguments for the review process, including topic and optional criteria.

Raises:

TypeError – If the object does not implement Display or WithBriefing.

Returns:

A review result containing identified problems and proposed solutions,

with a reference to the original object.

Return type:

Improvement