Hello,
I am trying to migrate the SequentialChain code from L3-Chains to use LangChain Expression Language (LCEL) but I can’t figure out the whole code, specifically code that runs as fast as the original LLMChain code.
I’ve tried the following:
chain_one = first_prompt | llm | StrOutputParser() # task: translate {Review} to {English_Review}
chain_two = {"English_Review": chain_one} | second_prompt | llm | StrOutputParser() # task: summarize English_Review into {summary}
chain_three = {"summary": chain_two, "Review": itemgetter("Review")} | third_prompt | llm | StrOutputParser() # task: find {language} of {Review}
chain_four = {"language": chain_three, "summary": chain_two} | fourth_prompt | llm | { "followup_message": StrOutputParser() } # task: generate follow up message to {summary} in {language}
chain_four.invoke({"Review": review})
and although it does work, it’s much slower than its “deprecated” version counterpart.
Anyone has any idea what the code should be?
Full code and repro available at GitHub dot com /rlondner/LangChain-for-LLM-Application-Development/blob/main/L3-Chains_Ollama_Chroma_Pinecone.ipynb
(I suggest updating using my requirements.txt file, as I have upgraded the code to LangChain 0.2.2).