Skip to main content

Evaluate blogs

Project description

VBI Evaluate Blogs

vbi_evaluate_blogs is a Python package designed to evaluate the quality of blog content comprehensively. It combines advanced text analysis, image evaluation, and fact-checking capabilities to ensure the quality, relevance, and credibility of the content. The package leverages Azure OpenAI and other state-of-the-art tools to provide accurate and insightful evaluations.

Features

1. Text Content Evaluation

  • Analyzes the grammar, structure, and coherence of the text.
  • Provides feedback on readability, keyword distribution, and SEO optimization.
  • Detects potential issues such as redundancy, lack of clarity, or missing components.

2. Image Relevance Analysis

  • Evaluates the quality and relevance of images in the content.
  • Ensures that images align with the context and purpose of the document.
  • Extracts and describes image content for deeper analysis.

3. Fact-Checking

  • Verifies the factual accuracy of the content using external sources.
  • Highlights potential inaccuracies or unsupported claims.
  • Ensures the credibility of the information presented.

4. Modular Design

  • Each feature is implemented as a separate module, allowing for flexible usage.
  • Users can choose to run specific evaluations or combine them as needed.

Installation

To install the package, use the following commands:

pip install vbi-evaluate-blogs
playwright install

Usage

1. Initialization

Before using the package, ensure you have set up your Azure OpenAI credentials in a .env file:

AZURE_OPENAI_API_KEY="your_api_key"
AZURE_OPENAI_ENDPOINT="your_endpoint"

2. Importing the Package

The package provides three main modules:

  • check_text: For text content evaluation.
  • check_image: For image relevance analysis.
  • check_fact: For fact-checking.

You can import these modules as follows:

from vbi_evaluate_blogs import check_text, check_image, check_fact
from langchain_openai import AzureChatOpenAI
from dotenv import load_dotenv
import os

load_dotenv()

3. Setting Up Azure OpenAI Models

Initialize the Azure OpenAI models for text and image processing:

text_llm = AzureChatOpenAI(
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
    model="o3-mini",
    api_version="2024-12-01-preview"
)

image_llm = AzureChatOpenAI(
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
    model="gpt-4o-mini",
    api_version="2024-08-01-preview",
    temperature=0.7,
    max_tokens=16000
)

4. Text Content Evaluation

Use the check_text module to evaluate the structure, grammar, readability, and SEO of the text content:

content = """
# Sample Blog Content
This is a sample blog content for evaluation.
"""

result = check_text(text_llm, content)
print("Text Evaluation Result:")
print(result)

5. Image Relevance Analysis

Use the check_image module to analyze images in the content:

content_with_images = """
![](https://example.com/sample-image.jpg)

# Sample Blog Content with Images
This is a sample blog content with images for evaluation.
"""

image_result = check_image(text_llm, image_llm, content_with_images)
print("Image Analysis Result:")
print(image_result)

6. Fact-Checking

Use the check_fact module to verify the factual accuracy of the content:

content_with_claims = """
# Sample Blog Content with Claims
The Earth is flat.
"""

fact_result = check_fact(text_llm, content_with_claims)
print("Fact-Checking Result:")
print(fact_result)

7. Comprehensive Evaluation

You can combine all three modules for a comprehensive evaluation:

content = """
![](https://example.com/sample-image.jpg)

# Sample Blog Content
This is a sample blog content with images and claims for evaluation.
"""

text_result = check_text(text_llm, content)
image_result = check_image(text_llm, image_llm, content)
fact_result = check_fact(text_llm, content)

print("Comprehensive Evaluation Result:")
print({
    "text": text_result,
    "images": image_result,
    "facts": fact_result
})

Command-Line Usage

You can also use the package via the command line for quick evaluations:

python -m vbi_evaluate_blogs --file path/to/your/blog.md

Additional Options

  • --text: Perform only text evaluation.
  • --images: Perform only image analysis.
  • --facts: Perform only fact-checking.

Example:

python -m vbi_evaluate_blogs --file path/to/your/blog.md --text --images

Advanced Usage

Customizing the Model

You can customize the Azure OpenAI model by providing additional parameters during initialization:

model = AzureChatOpenAI(api_key="your_api_key", temperature=0.7, max_tokens=1000)

Combining Modules

You can combine multiple modules to perform a comprehensive evaluation:

from vbi_evaluate_blogs import check_text, check_image, check_fact

content = """
# Sample Blog Content
This is a sample blog content with images and claims for evaluation.
"""

text_result = check_text(text_llm, content)
image_result = check_image(text_llm, image_llm, content)
fact_result = check_fact(text_llm, content)

combined_result = {
    "text": text_result,
    "images": image_result,
    "facts": fact_result
}

print("Combined Evaluation Result:", combined_result)

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

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

Source Distribution

vbi_evaluate_blogs-0.1.12.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

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

vbi_evaluate_blogs-0.1.12-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file vbi_evaluate_blogs-0.1.12.tar.gz.

File metadata

  • Download URL: vbi_evaluate_blogs-0.1.12.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for vbi_evaluate_blogs-0.1.12.tar.gz
Algorithm Hash digest
SHA256 c2a352dd36f723c9c2e5ea5a500417bbb396243131a3d0b621d091da6a5f9967
MD5 155eeee21d9aee405563af470f0e2eb0
BLAKE2b-256 5ff40e48c801216c0d29f88e4236c3a7bec93c3909d312f3c54ba590e7c25c17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vbi_evaluate_blogs-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 fe6f04961f43300fa4a566e1685aed7103d9fcd4271c7b9d68de622ae27be58e
MD5 24f36091a0cdfe3b1c9f9eb5ac37d898
BLAKE2b-256 b54679cbeb212c2de24f7fbfcb6edcb2896f90e7a46a33ff960faf7cc29ed235

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