Skip to main content

A Python library for content review, correction, and improvement in LLM applications.

Project description

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

ImproveConfig (loaded via fabricatio_core.CONFIG) exposes configurable template names:

  • review_string_template — template for review operations
  • fix_troubled_string_template — template for string correction
  • fix_troubled_obj_template — template for object correction

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

Project details


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.12-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fabricatio_improve-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 e3d09140f303a2d2a4d0c3fb3ea96bc030341af44a82205931cf3a6d1e4d7532
MD5 0659c68c61f4f9181395b3bff83f673a
BLAKE2b-256 e6feea65f726c831d596a4335bca03e1d8dd6c3c1b5a6aaf7909a486239cc02b

See more details on using hashes here.

Supported by

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