A collection of helper functions
Project description
Python Helpers
A collection of helper utils for my personal projects.
Installation
PyPI:
pip install tyler-python-helpers
Working from a git checkout (so scripts can use plain from tyler_python_helpers import ChatGPT with no sys.path hacks): install in editable mode once per environment:
pip install -e /path/to/python-helpers
# e.g. pip install -e ~/git/python-helpers
That registers the package with the interpreter the same way a normal install does. Layout under tyler_python_helpers/ (including the ai/ subpackage) is already standard; Python does not auto-import sibling folders next to your tools/ repo.
Alternatively, set PYTHONPATH to the checkout root if you prefer not to install.
If ImportError: cannot import name 'local_ai' while the repo already defines it, check for a stale user install that only had the old flat package (e.g. ~/.local/lib/python3.12/site-packages/tyler_python_helpers/). Remove it and point the interpreter at this repo, for example:
python3 -m pip uninstall tyler-python-helpers -y --break-system-packages
python3 -m pip install --user -e /path/to/python-helpers --break-system-packages
Or set PYTHONPATH to the checkout root.
AI (tyler_python_helpers.ai)
All AI-related code lives under tyler_python_helpers.ai. The top-level package re-exports the same names for convenience:
from tyler_python_helpers import ChatGPT, LocalAI, local_ai
ChatGPT
from tyler_python_helpers import ChatGPT
chat = ChatGPT()
val = chat.query("What is the capital of the moon?")
print(val)
ChatGPT chooses its backend from Cabinet at ai -> chatgpt -> backend:
"openai": uses the OpenAI Responses API"local": usesLocalAI/ Open WebUI
LocalAI
from tyler_python_helpers import LocalAI, local_ai
assert local_ai is LocalAI
print(local_ai().query("Summarize: ..."))
Cabinet layout
Cloud OpenAI (ChatGPT with ai -> chatgpt -> backend = "openai"):
| Path | Purpose |
|---|---|
ai → openai → key |
OpenAI API key |
In cloud mode, ChatGPT currently uses the fixed model gpt-4o.
Local Open WebUI — same usage shape as ChatGPT: LocalAI().query(...) or local_ai().query(...) (local_ai is an alias for LocalAI). Advanced: local_ai_messages([...]).
| Path | Purpose |
|---|---|
ai → local → openwebui_key |
Bearer token from Open WebUI |
ai → local → model |
Model id (e.g. qwen3:8b) |
ai → local → host |
Optional; default 192.168.1.102 |
ai → local → port |
Optional; default 3000 |
ChatGPT backend:
| Path | Purpose |
|---|---|
ai → chatgpt → backend |
"openai" (default) or "local" |
Legacy API key keys → openai is still read in cloud mode for ChatGPT only.
Library calls
from tyler_python_helpers import ChatGPT, LocalAI, local_ai, local_ai_messages, LocalOpenWebUIError
text = ChatGPT().query("Hello")
text = LocalAI().query("Hello")
text = local_ai().query("Hello")
text = local_ai_messages([{"role": "user", "content": "Hello"}])
Errors
Cloud and local requests may raise provider-specific errors: OpenAIError for cloud and LocalOpenWebUIError for local. Both modes may also raise ValueError when required Cabinet settings are missing or invalid.
Reference
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tyler_python_helpers-0.1.3.tar.gz.
File metadata
- Download URL: tyler_python_helpers-0.1.3.tar.gz
- Upload date:
- Size: 7.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b34541ad6df3b908373df48cd07f8d10e1ff40c067ab187e59860f0c5f74c64
|
|
| MD5 |
ce78c87cda4a188307b4a036506aa981
|
|
| BLAKE2b-256 |
8b62b9060deefb443f779374eb57a04547e1948bf22acd519182ee883a3d9351
|
File details
Details for the file tyler_python_helpers-0.1.3-py3-none-any.whl.
File metadata
- Download URL: tyler_python_helpers-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a19e20f0e232f26e61fe2829fa03232d4830a35d9648a9a1ebf5d808d8a2984a
|
|
| MD5 |
bec4593e81543693f787aef77479a235
|
|
| BLAKE2b-256 |
429f3d45b5d38b86e50f8fd9e7f5dcd540d9a8ccee4122dde7caab8d58a17e57
|