Chains are a core concept in LangChain. They link components (e.g., a prompt template, a model, an output parser) together in sequence. LLMChain is the most basic chain of all.
python
from langchain_openai import ChatOpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
prompt = PromptTemplate.from_template(
"What is the best name for a company that makes {product}?"
)
# Create an LLMChain
chain = LLMChain(llm=llm, prompt=prompt)
# Run the chain
response = chain.invoke({"product": "colorful socks"})
print(response)You should see
{'product': 'colorful socks', 'text': 'SoleMates'}