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.13.tar.gz (49.7 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.13-py3-none-any.whl (49.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vbi_evaluate_blogs-0.1.13.tar.gz
  • Upload date:
  • Size: 49.7 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.13.tar.gz
Algorithm Hash digest
SHA256 ff8ce7d3ad3da13f68cf0888b8afe5708825fe032e37565a61d7264cb6b080f3
MD5 b23cfe3a8f147fc7151b0d44c02a8f13
BLAKE2b-256 2000f970e15501cfdf233f9b41459d182c3237dd1d5d8ffcd13ca8528c866cdd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vbi_evaluate_blogs-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 b2492d8f69cc7d913953b5e4ac06507ac4246ebf0a5565f1e63405675206eee9
MD5 b3ae1c04af3fdd71539d4d4d63ec8508
BLAKE2b-256 2b9685eb9ab423a22188bc554170bc65e1fbd859ac794008a67414cd47e8dd1a

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