Convert the Creative Writing Workbench code from earlier exercise to use LangChain Execution Language (LCEL)
Creative writing exercise : ToT v1
Refer to the final chain graph in solution section to get an idea on final chain flow.
You need to pass multiple inputs to the prompts. Since the input variables will not be propagated automatically from one chain to another you will need to explicitly pass on the variables to the next chain. To do so, you can use a combination of RunnablePassthrough & RunnableParallel as shown in the code below. You may create a chains as sequential chain and then wrap sequential chain and variable passing using a Runnable as shown here.
RunnableParallel(
variable_to be_passed_to_next_chain=itemgetter('available_variable'),
output_variable_name = chain_sequence
)
Note that itemgetter is a shorthand for RunnablePassthrough + Lambda
The solution is built with Google Gemini. The solution is available under the Models folder. In order to use a different model, you need to change the LLM creation code in the solution notebook.
task_instructions=itemgetter('task_instructions')