Skip to main content

A Python library that counts letter frequency and compares numbers using OpenAI API

Project description

vibeutils

A Python utils library that counts letter frequency and compares numbers using OpenAI API.

Features

  • Count frequency of specific letters in text
  • Compare two numbers using AI
  • Case-sensitive and case-insensitive counting options
  • Uses OpenAI API for intelligent processing
  • Easy to use API
  • Ready for PyPI distribution

Performance

  • Time complexity: O(luck) and I use API calls to prevent prompt injection.

Installation

Install the package using pip:

pip install vibeutils

Setup

You need to provide your own OpenAI API key. Set it as an environment variable:

export OPENAI_API_KEY=your_openai_api_key_here

Usage

Letter Counting - vibecount()

from vibeutils import vibecount

# Count letter 'r' in "strawberry" (case-sensitive by default)
result = vibecount("strawberry", "r")
print(result)  # 2 ;)

# Case-insensitive counting
result = vibecount("Strawberry", "R", case_sensitive=False)
print(result)  # 2 ;)

# Case-sensitive counting (explicit)
result = vibecount("Strawberry", "R", case_sensitive=True)
print(result)  # 0 (no uppercase 'R' in "Strawberry")

Number Comparison - vibecompare()

from vibeutils import vibecompare

# Compare two integers
result = vibecompare(5, 10)
print(result)  # -1 (first number is smaller)

# Compare two floats
result = vibecompare(3.14, 2.71)
print(result)  # 1 (first number is larger)

# Compare equal numbers
result = vibecompare(7, 7)
print(result)  # 0 (numbers are equal)

Parameters

vibecount(text, target_letter, case_sensitive=True)

  • text (str): The input string to analyze
  • target_letter (str): The letter to count (must be a single character)
  • case_sensitive (bool, optional): Whether to perform case-sensitive counting (default: True)

vibecompare(num1, num2)

  • num1 (Union[int, float]): The first number to compare
  • num2 (Union[int, float]): The second number to compare

Return Values

  • vibecount(): Returns an integer representing the count of the target letter
  • vibecompare(): Returns an integer:
    • -1 if the first number is smaller than the second
    • 0 if the numbers are equal
    • 1 if the first number is larger than the second

Error Handling

Both functions raise:

  • ValueError: If OpenAI API key is not set or invalid arguments provided
  • Exception: If OpenAI API call fails

Requirements

  • Python 3.8+
  • OpenAI API key
  • Internet connection for API calls

Dependencies

  • openai>=1.0.0

Development

Running Tests

Install test dependencies:

pip install -r test-requirements.txt

Run tests:

pytest

Run tests with coverage:

pytest --cov=vibeutils

Run specific test file:

pytest tests/test_vibeutils.py

Test Structure

The test suite includes:

  • Unit tests for all function parameters and edge cases
  • Mock tests for OpenAI API calls (no actual API calls during testing)
  • Error handling validation
  • Input validation tests

License

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

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Note

This package uses the OpenAI API for processing, which requires an API key and internet connection. Each function call will make more than 1 request to OpenAI's servers and will consume API credits.

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

vibeutils-0.3.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

vibeutils-0.3.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file vibeutils-0.3.0.tar.gz.

File metadata

  • Download URL: vibeutils-0.3.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for vibeutils-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3ccd87d8e8eb6c9d4201afd67dadb696d978308e085fa910e18cfa6fed1b6f62
MD5 face46c05bb7ef5021804f822fbc2bf7
BLAKE2b-256 31e5a90ead0f432caa0befb115d5ad50113ffdbdf7db177750a8fcbeb5bb6191

See more details on using hashes here.

File details

Details for the file vibeutils-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: vibeutils-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for vibeutils-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2ae058b4df43413899b52a427b8a3387012456bb490d987984dc73562f218a5
MD5 00b9f2162c6bc7ff2164ab4444dfc55e
BLAKE2b-256 0142d4433df0291e07aee27847b92e0a6f74afdce0a122d89152598bf874c9f6

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