Skip to main content

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

Project description

vibeutils

A Python 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

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_vibecount.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 a 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.2.1.tar.gz (16.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.2.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vibeutils-0.2.1.tar.gz
  • Upload date:
  • Size: 16.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.2.1.tar.gz
Algorithm Hash digest
SHA256 c7aca48a2ecfbb267b249d062fa3784f4bc51a86b73f0132a739f6be1b8c2c74
MD5 34d6b9bf7350a5d6823a1d35c80b4bcf
BLAKE2b-256 29418c11ef282f4c16930d722be32be7c3b585b2ec62f6e3c4dd496de76acf0d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vibeutils-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98f8dc4a906fede6670c2a8d78093f22b24dcfc424fab0b012729e76d56f2650
MD5 142b1bd485d2d9304ca5544e412f2157
BLAKE2b-256 5874aa3538e11c51581fe719530a61b329bfd88a1db01e569e58ddf7060ccd82

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