
## Overview
In our [previous tutorial](https://hackmd.io/@metamike/langchain-magick-pt2), we walked through how to create your first `Chain` in [LangChain](https://python.langchain.com/docs/get_started/introduction.html) and how to quickly replicate this setup in [Magick](https://magickml.com/).
In this installment, we'll run through the process of making a `SimpleSequentialChain` and a `SequentialChain` in LangChain and Magick so you can see the difference in process for both. To test what we learn, we'll be creating a fictional roster for our fictional fantasy football team.
## LangChain
- If you haven't completed the [last tutorial](https://hackmd.io/@metamike/langchain-magick-pt2), ensure that you've done this before proceeding.
- Our first step in creating a `SimpleSequentialChain` is to create two chains - one for our team name and one for our team players. To do this, create another cell and input the below.
```python=
llm = OpenAI(temperature=0.85)
prompt_template_team = PromptTemplate(
input_variables = ['your_team'],
template = "I'm making a fantasy football roster with fictional players. Suggest a hilariously witty and culturally relevant name for the team, pulling from hall-of-fame {your_team} player names and key moments in {your_team} history."
)
team_chain = LLMChain(llm=llm, prompt=prompt_template_team)
prompt_template_fantasy_name = PromptTemplate(
input_variables = ['your_fantasy_name'],
template = "Suggest 11 humorous fictional football player names for the {your_fantasy_name} starting offensive lineup. Return it as a comma separated list."
)
fantasy_name_chain = LLMChain(llm=llm, prompt=prompt_template_fantasy_name)
```
- Now that we've created two chains (`team_chain` and `players_chain`), we now need to use import `SimpleSequentialChain` and execute the below. Here we are creating a `SimpleSequentialChain` using both the `team_chain` and `players_chain`.
```python=
from langchain.chains import SimpleSequentialChain
chain = SimpleSequentialChain(chains = [team_chain, fantasy_name_chain])
response = chain.run("The Dirty Birds of Fire & Ice")
print(response)
```
- After running the cell, we get this output: `1. Chuck E. Cheeseball, 2. Sammy Silverfoot, 3. Smash Mouth McSledge, 4. Piggyback Perkins, 5. Sir Speedster McGee, 6. Touchdown Tony, 7. Flea Flicker Finkleman, 8. Pocket Passer Potter, 9. Hammerhead Haywood, 10. Airborne Alley, 11. Big Rig Reynolds`
- This looks great, but our output only includes the players, and not our initial team name. Create a new cell, which will look very similar to our prior cell, but will utilize the `output_key` field to connect our chains, whereby our `team_chain` `output_key` will be our only `players_chain` `input variables`.
```python=
llm = OpenAI(temperature=0.85)
prompt_template_team = PromptTemplate(
input_variables = ['your_team'],
template = "I'm making a fantasy football roster with fictional players. Suggest a hilariously witty and culturally relevant name for the team, pulling from hall-of-fame {your_team} player names and key moments in {your_team} history."
)
team_chain = LLMChain(llm=llm, prompt=prompt_template_team, output_key="your_fantasy_name")
prompt_template_fantasy_name = PromptTemplate(
input_variables = ['your_fantasy_name'],
template = "Suggest 11 humorous fictional football player names for the {your_fantasy_name} starting offensive lineup. Return it as a comma separated list."
)
fantasy_name_chain = LLMChain(llm=llm, prompt=prompt_template_fantasy_name, output_key="your_fantasy_roster")
```
- We can now use a `SequentialChain` to tie all this data together in our output, having our `team_chain` feed our `players_chain`.
```python=
from langchain.chains import SequentialChain
chain = SequentialChain(
chains = [team_chain, fantasy_name_chain],
input_variables = ['your_team'],
output_variables = ['your_fantasy_name', 'your_fantasy_roster']
)
chain({'your_team':'Atlanta Falcons'})
```
- After executing, our resulting output looks like this:
```
{'your_team': 'Atlanta Falcons',
'your_fantasy_name': "\n\nThe Dirty Birdy Falcons of Deion's Dreamland.",
'your_fantasy_roster': "\n\n1. Kickin' Deion, 2. Buzzin' Julio, 3. Power-Packin' Matt, 4. Rumblin' Ryan, 5. Silent-But-Deadly Devonta, 6. Super-Sly Tony, 7. Jukin'-Javon, 8. Catchin'-Coby, 9. Blitzin'-Beasley, 10.Dashin'-Drew, 11. Beast-Mode Freeman."}
```
## Magick
So how do we implement all this in Magick? Luckily Magick provides an incredibly easy way to create this chain. If you're not on the waitlist, sign up on the [Magick homepage](https://www.magickml.com/) (and DM me on Twitter at @itsmetamike for fast-tracked access), and if you are in alpha, follow the steps below.
- Following on from our last tutorial, all we need to do in order to reproduce our `SimpleSequentialChain` is hook our `Generate Text` node up another `Text Template` node with an input socket labeled `your_fantasy_name` and insert our prompt template into the text editor.

- To reproduce our `SequentialChain`, all we need to do is hook both our `Generate Text` nodes up to another `Text Template` node with two input sockets labeled `your_fantasy_name` and `your_fantasy_roster` and insert our output template into the text editor.

## Conclusion
Magick makes it very simple to implement many of LangChain's core features with a few clicks. If you haven’t already, [join the waitlist now](https://www.magickml.com/).

:::info
*MetaMike is virtual world experience developer and has a passion for contributing to the education and enablement of the open metaverse.*
Follow MetaMike
[Website](https://itsmetamike.xyz/) | [Twitter](https://twitter.com/itsmetamike) | [LinkedIn](https://www.linkedin.com/in/itsmetamike/)
*If you'd like to support me, my work shown above is available to mint or purchase [here](https://opensea.io/collection/metamike-editions).*