Developing the front-end with Streamlit
Now that we have seen the logic behind an LLM-powered StoryScribe, it is time to give our application a GUI. To do so, we will once again leverage Streamlit. As always, you can find the whole Python code in the GitHub book repository at https://github.com/PacktPublishing/Building-LLM-Powered-Applications.
As per the previous sections, you need to create a .py
file to run in your terminal via streamlit run file.py
. In our case, the file will be named storyscribe.py
.
The following are the main steps to set up the front-end:
- Configuring the application webpage:
st.set_page_config(page_title="StoryScribe", page_icon="") st.header(' Welcome to StoryScribe, your story generator and promoter!') load_dotenv() openai_api_key = os.environ['OPENAI_API_KEY']
- Initialize the dynamic variables to be used within the placeholders of the prompts:
topic = st.sidebar.text_input...