Spaces:
Runtime error
Runtime error
File size: 1,140 Bytes
6d7e251 43c8cc4 6d7e251 |
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 |
import os
from constants import openai_key
from langchain_openai import OpenAI
import streamlit as st
from langchain import PromptTemplate
from langchain.chains import LLMChain
from langchain.chains import SimpleSequentialChain
#openai_key="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"
os.environ["OPENAI_API_KEY"]=openai_key
st.title('Award for a reason...')
input_text=st.text_input("Search the person you want it will show all awards he/she has ever got")
first_input_prompt=PromptTemplate(
input_variables=['name'],
template="Tell me about celebrity {name}"
)
llms=OpenAI(temperature=0.8)
chain=LLMChain(llm=llms,prompt=first_input_prompt,verbose=True,output_key='person')
second_input_prompt=PromptTemplate(
input_variables=['person'],
template="All Awards list {person} he has ever got "
)
chain2=LLMChain(llm=llms,prompt=second_input_prompt,verbose=True,output_key='dob')
parent_chain=SimpleSequentialChain(chains=[chain2],verbose=True)
# if input_text:
# st.write(llms(input_text))
# if input_text:
# st.write(chain.run(input_text))
if input_text:
st.write(parent_chain.run(input_text)) |