Learning AI Agent Programming (with DSPy)

Just realized that I haven’t written down any blogs for about a year. There’s much good learning and experience over the last year that I didn’t get a chance to write it down. It’s a good time to get dust off this blog and get back to the writing habit again.

A Dive Into AI Agent Programming

Recently I got really interested in AI Agent programming. And I spent some time in diving into understanding DSPy. At first I was a little perplexed by starting to read its papers (which focused more on program optimization than actual programming). But once I understood its design I immediately fell in love with it, as its design philosophy resonated with me very strongly.

You can specify and start writing an LLM agent program right away with just a few lines of Python:

1
2
3
4
sentence = "it's a charming and often affecting journey."  # example from the SST-2 dataset.

classify = dspy.Predict('sentence -> sentiment: bool') # we'll see an example with Literal[] later
classify(sentence=sentence).sentiment

(Examples from https://dspy.ai/learn/programming/signatures/.)

And I can quickly craft a few agents and combine them together to make an agentic workflow.

Read More