Spaces:
Running
Running
import streamlit as st | |
from model import chat_chain | |
caption_examples_file_path = "./data/caption_examples.txt" | |
with open(caption_examples_file_path, "r") as file: | |
caption_examples = file.read() | |
if "visibility" not in st.session_state: | |
st.session_state.visibility = "visible" | |
st.session_state.disabled = False | |
st.session_state.placeholder = "Example: Generate post about backpack Black Mamba with volume of 22 liters" | |
st.set_page_config( | |
page_title="Backpack Title Generator", | |
page_icon="π" | |
) | |
st.write("# Welcome to InstaGPT! ππ") | |
st.markdown("Write captions for backpacks in the style of Osprey") | |
text_input = st.text_input( | |
"Enter some text π", | |
label_visibility=st.session_state.visibility, | |
disabled=st.session_state.disabled, | |
placeholder=st.session_state.placeholder, | |
) | |
st.write("Examples:") | |
st.write("Generate post about backpack Black Mamba with volume of 22 liters") | |
st.write("Write a post about giveaway of 3 backpacks from new collection") | |
st.write("Create new post about backpack Adventure for 250 dollars") | |
generate_response = st.button("Generate") | |
if text_input: | |
st.write("You entered:", text_input) | |
if generate_response: | |
if text_input == "": | |
st.write("Please enter some text.") | |
else: | |
response = chat_chain.invoke( | |
{ | |
"example": caption_examples, | |
"question": text_input, | |
} | |
) | |
st.write("Generated:", response) | |