Skip to main content

A new package that uses large language models and pattern matching to perform structured similarity comparisons between textual content based on normalized compression distance. Users provide multiple

Project description

Compario

PyPI version License: MIT Downloads LinkedIn

Structured Text Similarity Comparison with Large Language Models

Compario is a Python package that leverages Normalized Compression Distance (NCD) and Large Language Models (LLMs) to perform structured similarity comparisons between textual content. It analyzes user-provided text snippets, computes similarity scores, and returns formatted results—ideal for automated content comparison without processing raw documents directly.


🔧 Installation

Install via pip:

pip install compario

🚀 Quick Start

Basic Usage

from compario import compario

# Example: Compare two text snippets
user_input = """
Text 1: "The quick brown fox jumps over the lazy dog."
Text 2: "A fast brown fox leaps across the sleepy canine."
"""
response = compario(user_input)
print(response)

Custom LLM Integration

By default, Compario uses ChatLLM7 (from langchain_llm7). You can override it with any LangChain-compatible LLM:

Using OpenAI

from langchain_openai import ChatOpenAI
from compario import compario

llm = ChatOpenAI()
response = compario(user_input, llm=llm)

Using Anthropic (Claude)

from langchain_anthropic import ChatAnthropic
from compario import compario

llm = ChatAnthropic()
response = compario(user_input, llm=llm)

Using Google Generative AI

from langchain_google_genai import ChatGoogleGenerativeAI
from compario import compario

llm = ChatGoogleGenerativeAI()
response = compario(user_input, llm=llm)

🔑 API Key & Rate Limits

  • Default LLM (LLM7): Uses LLM7_API_KEY from environment variables or falls back to a default key.
  • Free Tier: Sufficient for most use cases (check LLM7 docs for limits).
  • Custom Key: Pass via api_key parameter or set LLM7_API_KEY in your environment:
    compario(user_input, api_key="your_api_key_here")
    
  • Get a Free Key: Register at LLM7

📝 Parameters

Parameter Type Description
user_input str The text(s) to compare (e.g., multiple snippets separated by newlines).
api_key Optional[str] LLM7 API key (defaults to LLM7_API_KEY env var).
llm Optional[BaseChatModel] Custom LangChain LLM (e.g., ChatOpenAI, ChatAnthropic).

📌 Key Features

Pattern Matching + NCD: Combines structured pattern analysis with compression-based similarity. ✅ Flexible LLM Support: Works with any LangChain-compatible model. ✅ No Raw Document Processing: Focuses on comparing extracted text snippets. ✅ Clear Output: Returns structured similarity results.


🐛 Issues & Support

For bugs or feature requests, open an issue on GitHub.


👤 Author


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

compario-2025.12.21102846.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

compario-2025.12.21102846-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file compario-2025.12.21102846.tar.gz.

File metadata

  • Download URL: compario-2025.12.21102846.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for compario-2025.12.21102846.tar.gz
Algorithm Hash digest
SHA256 efc712af4f12cb1c43009d94873de1feb2eeae205dc79b2a707fa8b48ab79fe0
MD5 12094c80d6efcc67b78f7fb1012f06da
BLAKE2b-256 2e3b594a69901c182bb38ac5b9261fd6385a6d9b75179591c104de840102df5d

See more details on using hashes here.

File details

Details for the file compario-2025.12.21102846-py3-none-any.whl.

File metadata

File hashes

Hashes for compario-2025.12.21102846-py3-none-any.whl
Algorithm Hash digest
SHA256 23acae1730bcac315486718c8190d741591845029357a1b61ce8d3d5a3e0a8e3
MD5 99ba6c1602eea8d8b2262f0852b3739c
BLAKE2b-256 dfd6da2f586df8a6ec5895f32122b06dd70ec94a6c5ec104294606dc2fa2b5ec

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