petNameGen / app.py
sharma-kanishka's picture
Upload 2 files
9d56548
raw
history blame contribute delete
849 Bytes
from langchain.llms import AI21
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
import streamlit as st
import os
import dotenv
dotenv.load_dotenv()
def get_resp(type,color):
llm=AI21(ai21_api_key=os.environ['AI21_API_KEY'],temperature=0.3)
prompt=PromptTemplate(input_variables=['type','color'],
template="suggest some pet names for a {type} of {color} color")
chain=LLMChain(llm=llm,prompt=prompt)
response=chain.run(type=type,color=color)
return response
st.set_page_config(page_title="PetName-Generator")
st.header("P-N-G")
col1,col2=st.columns([1,1])
with col1:
type=st.text_input("Enter type of animal:")
with col2:
color=st.text_input("Enter color of animal:")
submit=st.button("generate")
if submit:
st.write(get_resp(type,color))