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)  # 3

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

# 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.0.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.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vibeutils-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 4412d6275aba6b19b3e364774986d1e9afa586a86d4b34471ff81142b9faac50
MD5 303a26e8b19a1a343abd3b07db3c850a
BLAKE2b-256 c98abafbb187bf4aa29af661d5dad970bff3023dc9621c390861bc543ce37f92

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vibeutils-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70a997016fe09dc51b556427704e8d81d86695f6264eae2b5eb32299f7bc7e01
MD5 d7b8a57fbb4d6913e8d627219cf5f17d
BLAKE2b-256 bd8ec463e40f347fda7ff6c8938e128d00d06fbfb9d97b6d92ed2cef4d7af909

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