Skip to main content

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": uses LocalAI / 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

Metadata

Release files for tyler-python-helpers 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tyler-python-helpers 0.1.3
File Size Uploaded
tyler_python_helpers-0.1.3.tar.gz 7.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for tyler-python-helpers 0.1.3
File Interpreter ABI Platform
tyler_python_helpers-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 MB

Release files / tyler_python_helpers-0.1.3.tar.gz

Download URL tyler_python_helpers-0.1.3.tar.gz
Size 7.9 MB
Tags Source
SHA-256 checksum
How to use checksums
1b34541ad6df3b908373df48cd07f8d10e1ff40c067ab187e59860f0c5f74c64
BLAKE2b-256 checksum
How to use checksums
8b62b9060deefb443f779374eb57a04547e1948bf22acd519182ee883a3d9351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / tyler_python_helpers-0.1.3-py3-none-any.whl

Download URL tyler_python_helpers-0.1.3-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a19e20f0e232f26e61fe2829fa03232d4830a35d9648a9a1ebf5d808d8a2984a
BLAKE2b-256 checksum
How to use checksums
429f3d45b5d38b86e50f8fd9e7f5dcd540d9a8ccee4122dde7caab8d58a17e57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page