Put gremllms in your code. They are quite helpful.
Project description
gremllm
A slight upgrade to the Gremlins in your code, we hereby present GREMLLM. This utility class can be used for a variety of purposes. Uhm. Also please don't use this and if you do please tell me because WOW. Or maybe don't tell me. Or do.
Installation
pip install gremllm
Usage
from gremllm import Gremllm
# Be sure to tell your gremllm what sort of thing it is
counter = Gremllm('counter')
counter.value = 5
counter.increment()
print(counter.value) # 6?
print(counter.to_roman_numerals()) # VI?
Every method call and attribute access goes through a gremllm to decide what code to execute.
Key Features
- Dynamic Behavior: Objects implement methods and properties on-the-fly using LLM reasoning
- Wet Mode: Method calls return living gremllm objects instead of plain values for infinite chaining
- Verbose Mode: See exactly what code the LLM generates with
verbose=True - Multi-Model Support: Use OpenAI, Claude, Gemini, or local models via the
llmlibrary - Inheritance: Child objects automatically inherit
wetandverbosesettings - Smart Error Handling: Graceful fallbacks when libraries aren't available or code fails
Configuration
Configure your preferred LLM using the llm library:
# For OpenAI (default)
llm keys set openai
# For Claude
pip install llm-claude-3
llm keys set claude
# For local models
pip install llm-ollama
You can also specify which model to use when creating a gremllm:
from gremllm import Gremllm
# Use default model (gpt-4o-mini)
counter = Gremllm('counter')
# Use specific OpenAI model
counter = Gremllm('counter', model='gpt-4o')
# Use Claude
counter = Gremllm('counter', model='claude-3-5-sonnet-20241022')
# Use local model via Ollama
counter = Gremllm('counter', model='llama2')
Examples
Basic counter (see example/counter.py):
from gremllm import Gremllm
counter = Gremllm('counter')
counter.value = 0
counter.increment()
counter.increment(5)
counter.add_seventeen()
print(counter.current_value)
print(counter.value_in_hex)
counter.reset()
Shopping cart (see example/cart.py):
from gremllm import Gremllm
# Remind me to not shop at your store
cart = Gremllm('shopping_cart')
cart.add_item('apple', 1.50)
cart.add_item('banana', 0.75)
total = cart.calculate_total()
print(f"Cart contents: {cart.contents_as_json()}")
print(f"Cart total: {total}")
cart.clear()
Wet Mode
Wet mode creates an immersive experience where method calls return gremllm objects instead of plain values, allowing infinite chaining and interaction:
from gremllm import Gremllm
# Normal mode returns plain values
counter = Gremllm('counter')
result = counter.increment() # Returns 1 (plain int)
# Wet mode returns living gremllm objects
wet_counter = Gremllm('counter', wet=True)
result = wet_counter.increment() # Returns a gremllm number object
doubled = result.double() # Can call methods on the result!
squared = doubled.square() # Keep chaining forever!
Swimming pool simulator demonstrating wet mode (see example/wet_pool.py):
from gremllm import Gremllm
# Everything stays "wet" and alive in wet mode!
pool = Gremllm('swimming_pool', wet=True)
splash = pool.cannonball() # Returns a living splash object
ripples = splash.create_ripples() # Splash creates living ripples
fish = ripples.scare_fish() # Ripples interact with fish
# Infinite emergent behavior!
Verbose Mode
Debug and understand gremllm behavior by seeing the generated code:
from gremllm import Gremllm
# Enable verbose mode to see generated code
counter = Gremllm('counter', verbose=True)
result = counter.increment()
# Output shows:
# [GREMLLM counter.increment] Generated code:
# ==================================================
# _context['value'] = _context.get('value', 0) + 1
# result = _context['value']
# ==================================================
Other notes
OMG THIS ACTUALLY WORKS
Further Reading
For background on the concept of "gremlins" in code, see: Gremlins Three Rules: An Evolutionary Analysis
Project details
Release history Release notifications | RSS feed
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 gremllm-0.2.0.tar.gz.
File metadata
- Download URL: gremllm-0.2.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93a8333be6a07227f36c8c151ea7375bdf02be9f64b81b0a8eded300a41049e4
|
|
| MD5 |
b0ad618983f6333ef78072077ca93ace
|
|
| BLAKE2b-256 |
1cfad787bbb6eda424a86208fb9c0010293273898bfad98f64464332a251bb69
|
File details
Details for the file gremllm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gremllm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b1655b0e39899af3504996107d32c4a6f9e19ec52cc1023920454b52771e166
|
|
| MD5 |
b0eee096a60d69b744aa12b2156893bf
|
|
| BLAKE2b-256 |
f7709553644cb905867abe77c38bcff75176af5b4c3055af227b1444c69c952e
|