Download 2_sequential_chain.py from Abhisingh-18/Lang-Smith-Implementation: direct link, hf CLI and curl.
- Browser
- Download file 655 Bytes
-
https://huggingface.co/Abhisingh-18/Lang-Smith-Implementation/resolve/main/2_sequential_chain.py
- Command line
-
hf download hf://Abhisingh-18/Lang-Smith-Implementation/2_sequential_chain.py
-
curl -L -o 2_sequential_chain.py https://huggingface.co/Abhisingh-18/Lang-Smith-Implementation/resolve/main/2_sequential_chain.py
655 Bytes
| from langchain_openai import ChatOpenAI | |
| from dotenv import load_dotenv | |
| from langchain_core.prompts import PromptTemplate | |
| from langchain_core.output_parsers import StrOutputParser | |
| load_dotenv() | |
| prompt1 = PromptTemplate( | |
| template='Generate a detailed report on {topic}', | |
| input_variables=['topic'] | |
| ) | |
| prompt2 = PromptTemplate( | |
| template='Generate a 5 pointer summary from the following text \n {text}', | |
| input_variables=['text'] | |
| ) | |
| model = ChatOpenAI() | |
| parser = StrOutputParser() | |
| chain = prompt1 | model | parser | prompt2 | model | parser | |
| result = chain.invoke({'topic': 'Unemployment in India'}) | |
| print(result) | |