Option 3: Hard-coded approach with a sequential chain
The third and last option offers yet another way of implementing a multimodal application, which performs the following tasks:
- Generates a story based on a topic given by the user.
- Generates a social media post to promote the story.
- Generates an image to go along with the social media post.
We will call this application StoryScribe.
To implement this, we will build separate LangChain chains for those single tasks, and then combine them into a SequentialChain
. As we saw in Chapter 1, this is a type of chain that allows you to execute multiple chains in a sequence. You can specify the order of the chains and how they pass their outputs to the next chain. So, we first need to create individual chains, then combine them and run as a unique chain. Let’s follow these steps:
- We’ll start by initializing the story generator chain:
from langchain.chains import SequentialChain...