Spaces:
Running
Running
File size: 1,478 Bytes
10f51c3 67143f7 10f51c3 9e4b615 10f51c3 67143f7 10f51c3 107915c 67143f7 10f51c3 9e4b615 67143f7 9e4b615 67143f7 9e4b615 10f51c3 67143f7 10f51c3 67143f7 b429427 67143f7 b429427 67143f7 |
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 39 40 41 42 43 44 45 46 47 48 49 |
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)
|