The capability
What does it mean to treat the model as a component?
Think about any other part your app depends on, like a database or a payment API. You know what you send it and what comes back, and you wrap it in your own code so the rest of the app doesn't need to know which vendor you're using. Treating the model as a component means you handle it the same way. You send it the list of messages plus a few settings, and what you get back is text, or JSON if you ask for it, plus a count of the tokens you're billed for.
The model is a weird kind of component, though. If you send a database the same query twice, you get the same rows back, but a model can give you two different answers to the same input. The provider can also update it or retire it on their own schedule, so the model you tested last month might not be the one answering today. And on top of that, picking which model to use is your call, and that one choice changes both what you pay and how good the answers are.
So this module goes through the choices that let you build on something like that safely, and how you keep them all in one place in your code, so that changing them later doesn't mean touching everything else.
Where it shows up
This comes up pretty much any time your code does something with what the model sends back. A feature that tags incoming emails, for example, has to read the tag out of the reply, so it needs the output in a fixed shape that it can parse. Or say a team is moving from one provider to another, and now they have to find every place in the code where the model gets called. Both of those get a lot easier if every call goes through one function in your code.
Keep reading
The rest of this lesson is free with an account
Create a free account to read the remaining 8 sections. It takes about twenty seconds and there's nothing to pay. The same account opens the slide decks and CV reviews.
- 02The model is a part you choose
- 03The dials
- 04Getting JSON your code can trust
- 05The same prompt can answer differently next week
- 06One place that talks to the model
- and 3 more
That's the last one written so far
Pick your next module from the board.
