Chat models and init_chat_model
Notebook· 01.01· 90–120 min· Lesson 10 of 129
The notebook opens in your lab, in a new tab. If your server is stopped, it starts first (a few seconds).
By the end you can
- Explain why every LangChain chat model shares one interface (
BaseChatModel, aRunnable) and what a provider integration package adds. - Create the same model three ways:
ChatGroq(...),init_chat_model("groq:..."), and the course helpermastery.models.get_model(role), and choose between them. - Configure temperature, max tokens, timeouts and retries, and find the real defaults in the code when the docs disagree.
- Call a model with
invoke,streamandbatch, and pass aRunnableConfig(run_name,tags,metadata,max_concurrency). - Use the Jupyter magics
%pip,%envand%%time, and read a model's profile (capabilities) before you depend on it.
Before you start
Module 00 complete (course env lc-mastery, mastery installed editable, .env with GROQ_API_KEY).
Python in this lesson
Python guideNew hereInheritanceiter() and next()zip()The throwaway name _The | operator between objects (operator overloading)getattr(), setattr(), hasattr()*args**kwargsSeveral except blocks
