Install latest from pypi:
$ pip install solvekitDocumentation can be found hosted on this GitHub repository’s pages. Additionally you can find package manager specific guidelines on pypi respectively.
from solvekit import *Add a toolbar button by calling
add_btn
with a name, icon, code snippet, and tooltip. Here’s the simplest case —
a single-line Python snippet:
add_btn('dice', 'ii:lucide:dice-5', 'import random; dice_num = random.randint(1,6); print(f"🎲 You rolled a {dice_num}!")', 'Roll a dice!', lang='py')For longer scripts, use a triple-quoted string. This button picks a random answer and displays it with a short delay:
add_btn('magic8', '🔮', '''
import random
import time
answers = ["It is certain! 🎉","Ask again later 🤔","Don't count on it 😬","Absolutely! ✨","Try again tomorrow 😴","Without a doubt! 🚀"]
print(f"🔮 {random.choice(answers)}")
time.sleep(5)
''', 'Ask the Magic 8-Ball', lang='py')Buttons can also trigger AI prompts. This one asks the assistant to clean up the code cell above the current cursor position:
add_btn('cleanup', 'ii:lucide:wand-sparkles', '''
await add_msg(content="""Please clean up the code above:
1. **Fastcore docs format**: Add docstrings and a comment after each parameter (each param on its own line)
2. **General cleanup**: Improve naming, simplify logic, remove duplication
Keep the overall structure and behavior the same.""",
msg_type='prompt', run=True)
''', 'Clean up code above', lang='py')The same pattern works for any reusable prompt — here’s one that polishes prose and formatting:
add_btn('optimize', 'ii:lucide:pencil-line', '''
await add_msg(content="""Please optimize the cell input above:
1. **Clarity**: Make the content clearer and more concise
2. **Structure**: Improve formatting and organization
3. **Grammar & Style**: Fix any grammar issues and improve readability
Keep the original intent and meaning the same.""",
msg_type='prompt', run=True)
''', 'Optimize cell input above', lang='py')add_btn
gives you a single toolbar button — useful, but real workflows need
more. Here’s where solvekit is headed:
Dropdown menus. A single toolbar icon that expands into a list of actions, perfect for storing frequently-used prompts.
Token usage bar. A live progress bar showing context window consumption for the current session.
JS helper library. Clean wrappers around solveit internals —
solvekit.run_msg(), solvekit.upsert_msg() — so custom buttons are
readable and concise, no guessing at private APIs.