Chat with OpenAI in LangChain - #5

From the creator

With the advent of OpenAI's Chat-GPT API endpoint (ChatCompletion), LangChain quickly added support for the new endpoint. Unlike previous LLM endpoints, the chat endpoint takes multiple inputs and so has its own unique set of objects and methods. OpenAI's `ChatCompletion` endpoint consumes three types of input: - System message — this acts as an initial prompt to "setup" the behavior of the chat completion. - Human messages — these are human prompts (both current and past) that are fed into the model. - AI messages — past AI responses to the human prompts. The prior `Completion` endpoint used for other models, like OpenAI's `text-davinci-003`, only accepted a single `input` field. In `input`, we would write everything. Because of this difference, we now have the LangChain `ChatOpenAI` object alongside several new prompt templates and "message" objects. We'll explore how these are used in this chapter. 🔗 Code notebook: https://github.com/pinecone-io/examples/blob/master/learn/generation/langchain/handbook/04-langchain-chat.ipynb 🌲 LangChain ebook: https://pinecone.io/learn/langchain/ 🎙️ AI Dev Studio: https://aurelio.ai/ 🎉 Subscribe for Article and Video Updates! https://jamescalam.medium.com/subscribe https://medium.com/@jamescalam/membership 👾 Discord: https://discord.gg/c5QtDB9RAP 00:00 LangChain's new Chat modules 02:09 New LangChain chat in Python 03:14 Using LangChains ChatOpenAI object 04:36 Chat messages in LangChain 06:43 New chat prompt templates 09:05 LangChain human message prompt template 13:18 Using multiple chat prompt templates 17:42 F-strings vs. LangChain prompt templates 19:23 Where to use LangChain chat features? #artificialintelligence #nlp #openai #deeplearning #langchain

Stop watching · start building
Matched to Hugging Face

Makers residency 4th edition

Your idea can be anything. At our last workshops, people built plant-based nutrition businesses, a way to measure planetary resilience, crochet headwear and a way to connect lonely people living in the same building. An asset manager went on to raise an additional £25M on their fund within nine months. The fourth workshop is a full day at KOKO with Nick Sarafa, learning to build with Claude Code. Bring the thing you keep meaning to start. We’ll bring the pizza.

◆ Fri 13 Nov 2026 ◆ KOKO, London
Makers residency 4th edition
Live event
Makers residency 4th edition
Fri 13 Nov 2026
Find a job · 1 live role

Jobs in AI.
Apply now.

Apply once › get screened › meet the company

See all roles

More like this

Running one yourself?

List your AI event,
wherever it is.

A meetup, a workshop, a hackathon, a conference. Any city, or online. Tell us about it and it lands in front of people already learning this stuff.