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

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

📦 Installation

This package is part of the fabricatio monorepo and can be installed as an optional dependency using either pip or uv:

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

For a full installation that includes this package and all other components of fabricatio:

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

🔍 Overview

Provides tools for:

  • Content review and problem detection The content review and problem detection tool analyzes the input text to identify various issues. It uses natural language processing techniques to check for grammar errors, spelling mistakes, and semantic inconsistencies. For example, it can detect incorrect word usage, missing punctuation, and unclear sentence structures. It also looks for logical problems in the content, such as contradictions or incomplete arguments.
  • Problem-solution pair generation Once problems are detected, this feature generates appropriate solutions. It takes into account the nature of the problem and the context of the text. For grammar and spelling errors, it can suggest the correct words or phrases. For semantic issues, it can propose alternative ways to express the ideas. The solutions are presented in a clear and actionable format, making it easy for users to implement them.
  • Text correction and refinement The text correction and refinement tool applies the generated solutions to the original text. It not only fixes the identified problems but also refines the overall quality of the text. This includes improving the readability, style, and coherence of the content. For example, it can rephrase sentences to make them more concise and clear, and adjust the tone of the text to be more appropriate for the intended audience.
  • Improvement prioritization based on severity This feature prioritizes the detected problems based on their severity. It assigns a severity level to each problem, taking into account factors such as the impact on the meaning of the text, the frequency of occurrence, and the importance of the context. High - severity problems are given higher priority, ensuring that users focus on fixing the most critical issues first.
  • Interactive feedback loops with users The interactive feedback loops allow users to participate in the improvement process. After the initial analysis and solution generation, the tool presents the problems and solutions to the users. Users can then provide their own feedback, accept or reject the proposed solutions, and suggest alternative approaches. This iterative process ensures that the final improved text meets the users' expectations.

Built on top of Fabricatio's agent framework with support for asynchronous execution.

🧩 Usage Example

from fabricatio_improve.capabilities.correct import Correct
The `Correct` class is the core component for text correction. It uses a set of pre - trained models and rules to analyze the input text and generate correction suggestions. It can handle different types of text, including articles, reports, and emails.
from fabricatio_improve.models.improve import Improvement
The `Improvement` model represents the overall result of the text improvement process. It contains information about the detected problems, the proposed solutions, and the severity levels of each problem. It also provides methods for accessing and manipulating this information.
from fabricatio_improve.models.problem import Problem, Solution
The `Problem` class represents a detected issue in the text. It includes attributes such as the description of the problem, its location in the text, and its severity level. The `Solution` class represents the proposed solution for a problem. It contains the description of the solution and the steps to implement it.


async def improve_content():
    # Initialize corrector
    corrector = Correct()

    # Sample problematic text
    text = "Ths txt has many speling erors."

    # Get improvement suggestions
    improvement: Improvement = await corrector.correct(text)

    print(f"Found {len(improvement.problem_solutions)} issues:")
    for ps in improvement.problem_solutions:
        print(f"\nProblem: {ps.problem.description}")
        print(f"Location: {ps.problem.location}")
        print(f"Severity: {ps.problem.severity_level}/10")
        print(f"Solution: {ps.solution.description}")
        print(f"Steps: {', '.join(ps.solution.execute_steps)}")

📁 Structure

fabricatio-improve/
├── capabilities/     - Core improvement functionality
│   ├── correct.py    - Text correction capabilities
│   └── review.py     - Content review capabilities
└── models/           - Data models for improvements
    ├── improve.py    - Improvement result model
    ├── kwargs_types.py - Validation argument types
    └── problem.py    - Problem-solution pair definitions

🔗 Dependencies

Built on top of other Fabricatio modules:

  • fabricatio-core - Core interfaces and utilities
  • fabricatio-capabilities - Base capability patterns

📄 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.10.dev0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file fabricatio_improve-0.1.10.dev0-py3-none-any.whl.

File metadata

  • Download URL: fabricatio_improve-0.1.10.dev0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","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.10.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 836ee487dc46c51cb0a978582bc9d6ca9a345728e63ff21517ff00ed68b83b14
MD5 65d12f7b4b9994404333de8bff50c23f
BLAKE2b-256 1f0a21455c92eea8cb1b6f96b3d675b7b7984d6a7858b3b193e025c512016903

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