Skip to main content

fabricatio-improve

MIT Python Versions PyPI Version PyPI Downloads PyPI Downloads Build Tool: uv

Content review, correction, and improvement for LLM applications built on Fabricatio's agent framework.

Installation

pip install fabricatio[improve]
# or
uv pip install fabricatio[improve]

For a full installation with all Fabricatio components:

pip install fabricatio[full]
# or
uv pip install fabricatio[full]

Overview

fabricatio-improve provides two capability classes that integrate into the Fabricatio agent architecture:

  • Review — analyzes text, tasks, or objects to identify problems and propose solutions using LLM-driven evaluation against configurable criteria.
  • Correct — applies reviewed problems and solutions to fix troubled text or objects, including best-solution selection and template-based correction.

Key Classes

Capabilities

Class Base Classes Description
Review Rating, Propose Reviews content against a topic and criteria, producing an Improvement with identified problems and proposed solutions.
Correct Rating Decides best solutions from review results, then applies fixes to troubled objects or strings using templates.

Models

Model Description
Improvement Result of a review — holds focused_on topic and a list of ProblemSolutions. Supports interactive supervisor filtering and gathering multiple improvements.
Problem A detected issue with description (cause), severity_level (0-10), and location.
Solution A proposed fix with description (mechanism), execute_steps, feasibility_level, and impact_level.
ProblemSolutions A pair of one Problem with its candidate Solution list. Supports deciding the final solution and interactive editing.

KWArgs Types

Type Used By Description
ReviewKwargs Review Review parameters including required topic, optional criteria set, and rating_manual dict.
CorrectKwargs Correct Correction parameters including the improvement to apply.

Configuration

All options below are read through the fabricatio configuration chain (see the Configuration Guide). Set them under the [ext.improve] table in fabricatio.toml, equivalently under [tool.fabricatio.ext.improve] in pyproject.toml, or via FABRICATIO_EXT__IMPROVE__<FIELD_UPPER> environment variables.

[ext.improve]
review_string_template = "built-in/review_string"
fix_troubled_string_template = "built-in/fix_troubled_string"
fix_troubled_obj_template = "built-in/fix_troubled_obj"
Option Type Default Description
review_string_template str "built-in/review_string" The name of the review string template which will be used to review a string.
fix_troubled_string_template str "built-in/fix_troubled_string" The name of the fix troubled string template which will be used to fix a troubled string.
fix_troubled_obj_template str "built-in/fix_troubled_obj" The name of the fix troubled object template which will be used to fix a troubled object.

Access at runtime: from fabricatio_improve.config import improve_config.

Usage

Review

from fabricatio_improve.capabilities.review import Review


class MyAgent(Review):
    """An agent that can review content."""


async def review_content():
    agent = MyAgent()
    improvement = await agent.review_string(
        "The quick brown fox jump over the lazy dog.",
        topic="grammar",
        criteria={"subject-verb agreement", "spelling"},
        rating_manual={"spelling": "no typos: 10, minor typos: 5, many typos: 0"},
    )

    for ps in improvement.problem_solutions:
        print(f"Problem: {ps.problem.description} (severity: {ps.problem.severity_level}/10)")
        for sol in ps.solutions:
            print(f"  Solution: {sol.description}")
            print(f"  Steps: {', '.join(sol.execute_steps)}")

Correct

from fabricatio_improve.capabilities.correct import Correct
from fabricatio_improve.models.improve import Improvement
from fabricatio_improve.models.problem import Problem, ProblemSolutions, Solution


class MyCorrector(Correct):
    """An agent that can correct content."""


async def correct_content():
    corrector = MyCorrector()

    # Build an improvement from prior review
    problem = Problem(
        name="subject-verb agreement",
        cause="'jump' should be 'jumps' for third-person singular",
        severity_level=7,
        location="line 1",
    )
    solution = Solution(
        name="fix verb",
        mechanism="Change 'jump' to 'jumps'",
        execute_steps=["locate the verb 'jump'", "replace with 'jumps'"],
        feasibility_level=10,
        impact_level=5,
    )
    improvement = Improvement(
        focused_on="grammar",
        problem_solutions=[ProblemSolutions(problem=problem, solutions=[solution])],
    )

    corrected = await corrector.correct_string(
        "The quick brown fox jump over the lazy dog.",
        improvement,
    )
    print(corrected)

Structure

fabricatio-improve/
├── capabilities/
│   ├── correct.py       — Correct capability (apply fixes to content)
│   └── review.py        — Review capability (detect problems, propose solutions)
└── models/
    ├── improve.py        — Improvement result model
    ├── problem.py        — Problem, Solution, ProblemSolutions models
    └── kwargs_types.py   — KWArgs types for correction and review

Dependencies

  • fabricatio-core — core interfaces and utilities
  • fabricatio-capabilities — base capability patterns (Rating, Propose)
  • fabricatio-question — interactive prompts for supervisor check

License

MIT — see LICENSE

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fabricatio_improve-0.1.13-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file fabricatio_improve-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: fabricatio_improve-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fabricatio_improve-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 f35854acb0a7d146b4bc97274e3127fb73747faef803f7a827336ed980c8a19b
MD5 b87a226980a9527dd4a9098209d1820c
BLAKE2b-256 3726a24d75b2236206cb069947da716f26ca32f74b503453a1bbde48295bc460

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.13 This release

1 file

0.1.12

1 file

0.1.11

1 file

0.1.10

1 file

0.1.9

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page