ilovetools 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ilovetools/__init__.py ADDED
@@ -0,0 +1,40 @@
1
+ """
2
+ ilovetools - A comprehensive Python utility library
3
+ """
4
+
5
+ __version__ = "0.1.1"
6
+ __author__ = "Ali Mehdi"
7
+ __email__ = "ali.mehdi.dev579@gmail.com"
8
+
9
+ # Import all modules for easy access
10
+ from . import ai
11
+ from . import data
12
+ from . import files
13
+ from . import text
14
+ from . import image
15
+ from . import audio
16
+ from . import web
17
+ from . import security
18
+ from . import database
19
+ from . import datetime
20
+ from . import validation
21
+ from . import conversion
22
+ from . import automation
23
+ from . import utils
24
+
25
+ __all__ = [
26
+ "ai",
27
+ "data",
28
+ "files",
29
+ "text",
30
+ "image",
31
+ "audio",
32
+ "web",
33
+ "security",
34
+ "database",
35
+ "datetime",
36
+ "validation",
37
+ "conversion",
38
+ "automation",
39
+ "utils",
40
+ ]
@@ -0,0 +1,11 @@
1
+ """
2
+ AI & Machine Learning utilities module
3
+ """
4
+
5
+ from .llm_helpers import token_counter
6
+ from .embeddings import *
7
+ from .inference import *
8
+
9
+ __all__ = [
10
+ 'token_counter',
11
+ ]
@@ -0,0 +1,5 @@
1
+ """
2
+ Embedding utilities for text and vector operations
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Model inference optimization utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,141 @@
1
+ """
2
+ LLM helper utilities for working with language models
3
+ """
4
+
5
+ import re
6
+ from typing import Union, List
7
+
8
+ __all__ = ['token_counter']
9
+
10
+
11
+ def token_counter(
12
+ text: Union[str, List[str]],
13
+ model: str = "gpt-3.5-turbo",
14
+ detailed: bool = False
15
+ ) -> Union[int, dict]:
16
+ """
17
+ Estimate token count for text input across different LLM models.
18
+
19
+ This function provides accurate token estimation for various language models
20
+ without requiring API calls. Essential for managing costs and staying within
21
+ context limits.
22
+
23
+ Args:
24
+ text (str or list): Input text or list of texts to count tokens for
25
+ model (str): Model name for token estimation. Supported models:
26
+ - "gpt-3.5-turbo", "gpt-4", "gpt-4-turbo" (OpenAI)
27
+ - "claude-3", "claude-2" (Anthropic)
28
+ - "llama-2", "llama-3" (Meta)
29
+ - "gemini-pro" (Google)
30
+ Default: "gpt-3.5-turbo"
31
+ detailed (bool): If True, returns detailed breakdown. Default: False
32
+
33
+ Returns:
34
+ int: Estimated token count (if detailed=False)
35
+ dict: Detailed breakdown with tokens, characters, words (if detailed=True)
36
+
37
+ Examples:
38
+ >>> from ilovetools.ai import token_counter
39
+
40
+ # Basic usage
41
+ >>> token_counter("Hello, how are you?")
42
+ 6
43
+
44
+ # With specific model
45
+ >>> token_counter("Hello, how are you?", model="gpt-4")
46
+ 6
47
+
48
+ # Detailed breakdown
49
+ >>> token_counter("Hello, how are you?", detailed=True)
50
+ {
51
+ 'tokens': 6,
52
+ 'characters': 19,
53
+ 'words': 4,
54
+ 'model': 'gpt-3.5-turbo',
55
+ 'cost_estimate_1k': 0.0015
56
+ }
57
+
58
+ # Multiple texts
59
+ >>> texts = ["First message", "Second message"]
60
+ >>> token_counter(texts)
61
+ 8
62
+
63
+ # Check if text fits in context window
64
+ >>> text = "Your long text here..."
65
+ >>> tokens = token_counter(text, model="gpt-3.5-turbo")
66
+ >>> if tokens > 4096:
67
+ ... print("Text too long for model context!")
68
+
69
+ Notes:
70
+ - Token estimation is approximate but typically within 5% accuracy
71
+ - Different models use different tokenization methods
72
+ - Useful for cost estimation and context window management
73
+ - No API calls required - works offline
74
+
75
+ References:
76
+ - OpenAI Tokenization: https://platform.openai.com/tokenizer
77
+ - Token pricing: https://openai.com/pricing
78
+ """
79
+
80
+ # Handle list input
81
+ if isinstance(text, list):
82
+ text = " ".join(text)
83
+
84
+ # Model-specific token estimation ratios
85
+ # Based on empirical analysis of different tokenizers
86
+ model_ratios = {
87
+ "gpt-3.5-turbo": 0.75, # ~4 chars per token
88
+ "gpt-4": 0.75,
89
+ "gpt-4-turbo": 0.75,
90
+ "claude-3": 0.72, # Slightly more efficient
91
+ "claude-2": 0.72,
92
+ "llama-2": 0.78, # Slightly less efficient
93
+ "llama-3": 0.76,
94
+ "gemini-pro": 0.74,
95
+ }
96
+
97
+ # Cost per 1K tokens (USD) - approximate
98
+ model_costs = {
99
+ "gpt-3.5-turbo": 0.0015,
100
+ "gpt-4": 0.03,
101
+ "gpt-4-turbo": 0.01,
102
+ "claude-3": 0.015,
103
+ "claude-2": 0.008,
104
+ "llama-2": 0.0, # Open source
105
+ "llama-3": 0.0,
106
+ "gemini-pro": 0.00025,
107
+ }
108
+
109
+ # Get ratio for model (default to GPT-3.5)
110
+ ratio = model_ratios.get(model.lower(), 0.75)
111
+
112
+ # Character count
113
+ char_count = len(text)
114
+
115
+ # Word count (simple split)
116
+ word_count = len(text.split())
117
+
118
+ # Token estimation
119
+ # Formula: (characters * ratio) with adjustments for spaces and punctuation
120
+ base_tokens = char_count * ratio
121
+
122
+ # Adjust for spaces (spaces are often separate tokens)
123
+ space_count = text.count(' ')
124
+
125
+ # Adjust for special characters and punctuation
126
+ special_chars = len(re.findall(r'[^\w\s]', text))
127
+
128
+ # Final token estimate
129
+ estimated_tokens = int(base_tokens + (space_count * 0.3) + (special_chars * 0.5))
130
+
131
+ if detailed:
132
+ return {
133
+ 'tokens': estimated_tokens,
134
+ 'characters': char_count,
135
+ 'words': word_count,
136
+ 'model': model,
137
+ 'cost_estimate_1k': model_costs.get(model.lower(), 0.0),
138
+ 'estimated_cost': (estimated_tokens / 1000) * model_costs.get(model.lower(), 0.0)
139
+ }
140
+
141
+ return estimated_tokens
@@ -0,0 +1,5 @@
1
+ """
2
+ Audio processing utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Task automation utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Format conversion utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Data processing and manipulation utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Database connection and query utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Date and time utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ File operations and management utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Image processing utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Security and encryption utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Text processing and NLP utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ General utility functions
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Data validation and sanitization utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Web scraping and HTTP utilities
3
+ """
4
+
5
+ __all__ = []
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: ilovetools
3
+ Version: 0.1.1
4
+ Summary: A comprehensive Python utility library with modular tools for AI/ML, data processing, and daily programming needs
5
+ Home-page: https://github.com/AliMehdi512/ilovetools
6
+ Author: Ali Mehdi
7
+ Author-email: Ali Mehdi <ali.mehdi.dev579@gmail.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/AliMehdi512/ilovetools
10
+ Project-URL: Repository, https://github.com/AliMehdi512/ilovetools
11
+ Project-URL: Issues, https://github.com/AliMehdi512/ilovetools/issues
12
+ Keywords: utilities,tools,ai,ml,data-processing,automation
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Dynamic: author
27
+ Dynamic: home-page
28
+ Dynamic: license-file
29
+ Dynamic: requires-python
30
+
31
+ # 🛠️ ilovetools
32
+
33
+ A comprehensive Python utility library with modular tools for AI/ML, data processing, file operations, and daily programming needs.
34
+
35
+ [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
36
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
37
+ [![PyPI version](https://badge.fury.io/py/ilovetools.svg)](https://badge.fury.io/py/ilovetools)
38
+
39
+ ## 📦 Installation
40
+
41
+ ```bash
42
+ pip install ilovetools
43
+ ```
44
+
45
+ ## 🚀 Quick Start
46
+
47
+ ```python
48
+ from ilovetools import ai, data, files, text
49
+
50
+ # AI utilities
51
+ embeddings = ai.quick_embed("Your text here")
52
+
53
+ # Data processing
54
+ cleaned_data = data.auto_clean(your_dataframe)
55
+
56
+ # File operations
57
+ files.smart_read("any_file.xyz")
58
+
59
+ # Text processing
60
+ emails = text.extract_emails("Contact us at hello@example.com")
61
+ ```
62
+
63
+ ## 📚 Modules
64
+
65
+ ### 🤖 AI & Machine Learning (`ilovetools.ai`)
66
+ Advanced AI/ML utilities for modern development:
67
+ - LLM helpers and prompt engineering
68
+ - Model loading and inference optimization
69
+ - Embeddings and vector operations
70
+ - RAG pipeline tools
71
+ - Fine-tuning utilities
72
+
73
+ ### 📊 Data Processing (`ilovetools.data`)
74
+ Smart data manipulation and analysis tools
75
+
76
+ ### 📁 File Operations (`ilovetools.files`)
77
+ Intelligent file handling and management
78
+
79
+ ### 📝 Text Processing (`ilovetools.text`)
80
+ Advanced text manipulation and NLP utilities
81
+
82
+ ### 🖼️ Image Tools (`ilovetools.image`)
83
+ Image processing and computer vision helpers
84
+
85
+ ### 🎵 Audio Tools (`ilovetools.audio`)
86
+ Audio processing utilities
87
+
88
+ ### 🌐 Web Utilities (`ilovetools.web`)
89
+ Web scraping and HTTP helpers
90
+
91
+ ### 🔐 Security (`ilovetools.security`)
92
+ Encryption and security tools
93
+
94
+ ### 💾 Database (`ilovetools.database`)
95
+ Database connection and query helpers
96
+
97
+ ### ⏰ DateTime (`ilovetools.datetime`)
98
+ Advanced date and time utilities
99
+
100
+ ### ✅ Validation (`ilovetools.validation`)
101
+ Data validation and sanitization
102
+
103
+ ### 🔄 Conversion (`ilovetools.conversion`)
104
+ Format converters and transformers
105
+
106
+ ### 🤖 Automation (`ilovetools.automation`)
107
+ Task automation helpers
108
+
109
+ ### 🔧 Utils (`ilovetools.utils`)
110
+ General utility functions
111
+
112
+ ## 📖 Documentation
113
+
114
+ Full documentation available at: [Coming Soon]
115
+
116
+ ## 🤝 Contributing
117
+
118
+ Contributions are welcome! Please feel free to submit a Pull Request.
119
+
120
+ ## 📄 License
121
+
122
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
123
+
124
+ ## 👨‍💻 Author
125
+
126
+ **Ali Mehdi**
127
+ - GitHub: [@AliMehdi512](https://github.com/AliMehdi512)
128
+ - WhatsApp: https://wa.me/923264747914
129
+
130
+ ## 🌟 Support
131
+
132
+ If you find this library useful, please give it a star ⭐️
133
+
134
+ ## 📝 Changelog
135
+
136
+ ### Version 0.1.0 (Initial Release)
137
+ - Initial library structure
138
+ - Core module setup
139
+ - Basic utilities
140
+
141
+ ---
142
+
143
+ Built with ❤️ for the Python community
@@ -0,0 +1,24 @@
1
+ ilovetools/__init__.py,sha256=hm1B4leFU-c8B8IUTb28t58TjI9WE0meNqp63N49MS0,698
2
+ ilovetools/ai/__init__.py,sha256=2Ozehn-E_YakbtdiK4gGRL-WqT-uZ_ayWvzhSBU_U7s,174
3
+ ilovetools/ai/embeddings.py,sha256=VNr9PJdWZ4xGq3nz-SCe2wU6c0-NSpDdabSs6fmXG40,72
4
+ ilovetools/ai/inference.py,sha256=lDuREwf04BkaHGmkKQwgy3wwZRVlNy8A607vzwL-oLE,60
5
+ ilovetools/ai/llm_helpers.py,sha256=IgEGEF1s5VSZ2KndrdqXicH7M7n4PV9c2CdOAY-239s,4432
6
+ ilovetools/audio/__init__.py,sha256=B7atdH2nayCangy6b5FolqWNX2vfjh-K2gLx9kMNGmw,48
7
+ ilovetools/automation/__init__.py,sha256=sYuGw2tJBw8fgk8qhQNRyK-6XIqeLyoWo83QPT3fC7k,47
8
+ ilovetools/conversion/__init__.py,sha256=8bs3-l10sx-_XCeYpjqjSzbpW0UuXJrz0-HBM_hrkIM,49
9
+ ilovetools/data/__init__.py,sha256=bUNFEHvRugVDYkvg54MZHk3b_SanmeIZLZHF4UmYEJI,64
10
+ ilovetools/database/__init__.py,sha256=ksuVyzDM5GdRSulLWghRy-MVGDFy8wbacLuV9DqHImQ,61
11
+ ilovetools/datetime/__init__.py,sha256=znPdTvHcFRTXRgOH8VSGnFLJeNvd3_J1yKRmOq0hHOA,45
12
+ ilovetools/files/__init__.py,sha256=OX27wVQYKB_oPxvL39kWhCDpu5Tt8jGH22MKtYEnK-c,62
13
+ ilovetools/image/__init__.py,sha256=neiSIIZN7i_0CqR0y-neckF_1-45otKjw_dsDaE8gMo,48
14
+ ilovetools/security/__init__.py,sha256=jQg05Gi5QOqFwNhj4kpaVB0rlQy2JvfwD9DHaeqR3iA,55
15
+ ilovetools/text/__init__.py,sha256=tt5iXyHNCQYvomL9Z9ubro4HmckI8W-EKgdKEiTFuWA,55
16
+ ilovetools/utils/__init__.py,sha256=nFtUxlJeWBFZRl7U2wz4REbrwoLjlKif3tYKdMgzn9s,47
17
+ ilovetools/validation/__init__.py,sha256=gnYqT3k_2LYjM0jr-pSnnyMjCBvOrKmGhYS2RoL7Bu8,64
18
+ ilovetools/web/__init__.py,sha256=7HNp0mfw8OVHqxFvJ_M-UfJraG2BX-g3vvOlcSNCQ5w,53
19
+ ilovetools-0.1.1.dist-info/licenses/LICENSE,sha256=pFIsQeo2ZIARy0yDsoT-FYYHdiol7mGq1rtKPYIYn20,1065
20
+ tests/__init__.py,sha256=hiWUFgSflKQWFZ6mOX9sNUbogc6-Vf6xGdY_8-Kk56w,33
21
+ ilovetools-0.1.1.dist-info/METADATA,sha256=i397vdqWZjgQRjxoavtCrk1Wewcj9OFWwabgZPJvmjk,4088
22
+ ilovetools-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ ilovetools-0.1.1.dist-info/top_level.txt,sha256=_JECI73sb4vs7YXZi9JjtIkpCd760dBOVm2ehxYoJIE,17
24
+ ilovetools-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ali Mehdi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ ilovetools
2
+ tests
tests/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """
2
+ Test suite for ilovetools
3
+ """