Pr

Promptic – LLM superpowers for your Python functions (in ~80 lines)

Hacker News

Promptic – LLM superpowers for your Python functions (in ~80 lines)

Hey HN, I've been building quite a few Python services that use LLMs lately. While tools like Magentic and Marvin are great, and served as inspiration for this project, I found myself needing something simpler and more focused on my core use cases. So I created Promptic https://github.com/knowsuchagency/promptic . It's a small Python library that does one thing really well: turns your Python functions into LLM-powered wizards. How does it work? * Decorate: Add the @promptic decorator to your function. * Write a prompt: Use your function's docstring to explain what you want the LLM to do. * Get structured results: If your function returns a Pydantic model, Promptic automatically parses the LLM's response into that model. Example: ```python from promptic import promptic from pydantic import BaseModel @promptic def us_president(year): """Who was the President of the United States in {year}?""" print(us_president(2000)) # The President of the United States in 2000 was Bill Clinton until January 20th, when George W. Bush was inaugurated as the 43rd President. class Capital(BaseModel): country: str capital: str @promptic def get_capital(country) -> Capital: """What's the capital of {country}?""" print(get_capital("France")) # country='France' capital='Paris' @promptic(stream=True) def haiku(subject: str, adjective: str, verb: str) -> str: """Write a haiku about {subject} that is {adjective} and {verb}.""" print("".join(haiku("nature", "beautiful", "inspires"))) # Vibrant green leaves sway # Birds sing melodies of joy # Nature's perfect dance ``` Why use it? * Simplicity: No complex abstractions or frameworks to learn. * Focus: Promptic handles LLM interactions, you focus on your business logic. * Pydantic: Get type-safe, structured results without writing JSON parsing code. * Batteries included: Supports streaming responses and works with any LLM provider via LiteLLM. Inspired by the real world, Promptic distills the most effective patterns I've discovered while building LLM-powered services in production. It's designed for practical, everyday use cases. Feedback welcome! Let me know what you think. I'm eager to hear how Promptic fits (or doesn't) into your workflow. Happy coding!

Share card

Actual performance

2points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Indie HackersFits the IH revenue-focused audience · Strong signals: supports, created · Missing: reddit linkedin, podcasting, latex
93%93% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Product HuntOn track for Day 1 leaderboard · Strong signals: agent, model, agentic · Missing: mac, agents, macos
63%63% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: ide, 000, io · Missing: https docs, excited, just released
61%61% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRLess likely to generate early MRR · Strong signals: way · Missing: mobile apps, ios, personal
45%45% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
25%25% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
11%11% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Strong signals: real world · Missing: web3, chat, crypto
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Incorrect prediction on native model

Similar products

Ha
Hangman in 3 lines of Python57%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Hangman in 3 lines of Python

Hacker News58
AI
AI-assert – Constraint verification for LLM outputs (278 lines, Python)36%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

AI-assert – Constraint verification for LLM outputs (278 lines, Python)

Hacker News1
Po
Pongo – 80% Fewer LLM Hallucinations with one LoC67%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Pongo – 80% Fewer LLM Hallucinations with one LoC

Hacker News3
A
A very simple Lisp interpreter in 250 lines of literate Python70%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

A very simple Lisp interpreter in 250 lines of literate Python

Hacker News5
Re
Retirement Calculator in 8 lines of Python52%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Retirement Calculator in 8 lines of Python

Hacker News1
Qu
Querying 50k Gameservers in 100 lines of Python46%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Querying 50k Gameservers in 100 lines of Python

Hacker News1
A
A Python module to steer LLM outputs43%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

A Python module to steer LLM outputs

Hacker News2
Bu
Build python ASTs in 502 lines of python without using modules65%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Build python ASTs in 502 lines of python without using modules

Hacker News2
Fu
FuzzyFinder – in 10 lines of Python53%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

FuzzyFinder – in 10 lines of Python

Hacker News10
20
2048 in ten 60-width lines of python50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

2048 in ten 60-width lines of python

Hacker News2