I am new to langchain and langserve. the langserve definition goes as "LangServe helps developers deploy LangChain runnables and chains as a REST API." But could not understand the basic differneces between the two.
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
model = ChatOpenAI()
prompt = ChatPromptTemplate.from_template("tell me a joke about {topic}")
chain = prompt | model
chain = prompt | model is this a chain or runnable. If it is a chain, then how a runnable is written and what is the need for a runnable?
We can create components of the chain using Runnable methods. For example, consider the code below:
As you can see in the code above both runnable and chain are sued. However, I am defining one component of the chain as a runnable component. This is done because now I can pass two arguments to the chain and also now we can run these runnables in parallel way.
Therefore, runnable and chain cannot be compared but instead components of the chain can be created as a runnable.