Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views1 page

Car Launch Year & Top Models Query

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Car Launch Year & Top Models Query

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

from langchain_openai import OpenAI

from langchain import PromptTemplate

from langchain.chains import LLMChain


from langchain.chains import SequentialChain

llm = OpenAI(temperature = 0.5)


prompt1 = PromptTemplate(
input_variables = ['name'],
template = "Tell me when the car model {name} was launched"
)
chain1 = LLMChain(llm = llm, prompt = prompt1, verbose = True, output_key = 'year')

prompt2 = PromptTemplate(
input_variables = ["year"],
template = "Tell me the top 5 car model in the year {year}"
)
chain2 = LLMChain(llm = llm, prompt = prompt2, verbose = True, output_key = 'top
5')

final_chain = SequentialChain(
chains = [chain1,chain2],
input_variables = ['name'],
output_variables = ['year', 'top 5'], verbose = True)

response = final_chain({"name": "Ford"})


print(response)

You might also like