loglinecreator / app.py
eaglelandsonce's picture
Update app.py
81c9e58
import streamlit as st
from utils import generate_logline
# Applying Styling
st.markdown("""
<style>
div.stButton > button:first-child {
background-color: #0a99fa;
color:#ffffff;
}
div.stButton > button:hover {
background-color: #ffffff;
color:#0a99fa;
}
</style>""", unsafe_allow_html=True)
# Creating Session State Variable
if 'API_Key' not in st.session_state:
st.session_state['API_Key'] = ''
st.title('📝 Logline Creator')
# Sidebar to capture the OpenAi API key
st.sidebar.title("🗝️")
st.session_state['API_Key'] = st.sidebar.text_input("Paste in your OPENAI API key?", type="password")
st.sidebar.markdown('Logline Generator: Input a brief story description, select creativity and receive a story title and logline in return. Designed for my cloud Meetup as a demonstration of simple chaining using LangChain. Check out our Cloud Meetup at https://www.meetup.com/florence-aws-user-group-meetup It is free to join! Additionally, here is a video on how this was built https://www.youtube.com/watch?v=rh4cJmv0Bxg')
# Captures User Inputs
prompt = st.text_input('Please provide a short description of your story', key="prompt")
creativity = st.slider('Creativity ✨ - (0 LOW || 1 HIGH)', 0.0, 1.0, 0.5, step=0.1)
submit = st.button("Generate a Logline for me")
if submit:
if st.session_state['API_Key']:
title, logline = generate_logline(prompt, creativity, st.session_state['API_Key'])
# Let's generate the script
st.success('Enjoy the Logline️')
# Display Title
st.subheader("Title:🔍")
st.write(title)
# Display Video Script
st.subheader("Your Logline:🔥")
st.write(logline)
else:
st.error("Please provide your OpenAI API key in the left column.....")