Back to articles
I stopped writing prompts and started writing Python

I stopped writing prompts and started writing Python

via Dev.toAli Raza

For an year, I treated LLMs like a command line. Type instructions, pray for output. Tweaking wording, adding "IMPORTANT:", moving sentences around like a ritual. Then I found DSPy. Here's what changed. ─── The prompt treadmill I had folders of prompts. v1.txt, v2_final.txt, v2_final_REALLY_final.txt. None of them documented why they worked. The worst part? When something broke, I couldn't tell if it was the prompt, the model, or the data. No version control. No tests. Just vibes. ─── The DSPy shift DSPy (from Stanford NLP) flips the model: You don't write prompts. You write Python. class AnalyzeStartup ( dspy . Signature ): """ Analyze a startup pitch. """ pitch : str = dspy . InputField () viability_score : int = dspy . OutputField () strengths : list [ str ] = dspy . OutputField () weaknesses : list [ str ] = dspy . OutputField () verdict : str = dspy . OutputField () That's it. No You are an expert startup analyst.... No Respond in JSON format.... Just types and descriptions. DSPy

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles