|
import streamlit as st |
|
from langchain.chains.llm import LLMChain |
|
from langchain.chains.sequential import SequentialChain |
|
from langchain_groq import ChatGroq |
|
from langchain.prompts import PromptTemplate |
|
|
|
st.title('LEADER DATABASE') |
|
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') |
|
|
|
|
|
|
|
parent=SequentialChain(chains=[chain1,chain2,chain3], |
|
input_variables=['A'], |
|
output_variables=['person','dob','election win'] |
|
) |
|
|
|
if sub: |
|
st.write(parent({'A':leader_name})) |
|
|