A hands-on study of LangChain core concepts.
Learned how to instantiate and invoke LLMs using LangChain's chat model wrappers.
ChatOllama— run local models via OllamaChatAnthropic— call Claude models via the Anthropic API
Learned how to structure inputs to an LLM using prompt templates.
PromptTemplate— for simple string-based prompts with variablesChatPromptTemplate— for multi-turn message-based prompts; supports variable substitution and LCEL chaining
Learned how to parse and transform LLM responses into usable formats.
StrOutputParser— extracts the response content as a plain stringJsonOutputParser— parses the response as a JSON dict (requires the LLM to follow JSON format strictly)with_structured_output(PydanticModel)— a more reliable approach using a PydanticBaseModelto enforce structured output at the model level
Learned that PromptTemplate, LLMs, and Output Parsers all inherit from Runnable, meaning they all share a common .invoke() interface.
LangChain Expression Language (LCEL) allows these components to be connected with the | operator, forming a chain:
chain = prompt_template | llm | output_parser
chain.invoke({"country": "France"})A chain itself is also a Runnable, so chains can be composed with other chains:
final_chain = {"country": country_chain} | capital_chain
final_chain.invoke({"continent": "Europe", "information": "..."})| File | Topic |
|---|---|
1. chat.ipynb |
LLM instantiation and basic invocation |
2. prompt.ipynb |
PromptTemplate and ChatPromptTemplate |
3. output_parser.ipynb |
StrOutputParser, JsonOutputParser, structured output with Pydantic |
4. runnable.ipynb |
Runnables, LCEL, and chaining |