File size: 1,390 Bytes
ddf62e5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import streamlit as st #deployment
from langchain.chains.llm import LLMChain #individual chain
from langchain.chains.sequential import SequentialChain #combine chains
from langchain_groq import ChatGroq # llm model
from langchain.prompts import PromptTemplate #prompt for query
st.title('LEADER DATABASE') #title
leader_name=st.text_input('Enter The Famous leader_name from India.')
sub=st.button('SUBMIT')
LLM_model=ChatGroq(temperature=0.6,
groq_api_key='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')
prompt1=PromptTemplate(input=['A'],
template='tell me about {A} in 20 words.')
chain1=LLMChain(llm=LLM_model,prompt=prompt1,output_key='person')
prompt2=PromptTemplate(input=['person'],
template='what is date of birth of this {person}.')
chain2=LLMChain(llm=LLM_model,prompt=prompt2,output_key='dob')
prompt3=PromptTemplate(input=['dob'],
template='mention how many time win elections {dob}.')
chain3=LLMChain(llm=LLM_model,prompt=prompt3,output_key='election win')
#combine all the chains in sequence
parent=SequentialChain(chains=[chain1,chain2,chain3],
input_variables=['A'],
output_variables=['person','dob','election win']
)
if sub:
st.write(parent({'A':leader_name}))
|