eaglelandsonce/simplevectorization
10
1import streamlit as st2from utils import generate_vector3 4# Applying Styling5st.markdown("""6<style>7div.stButton > button:first-child {8 background-color: #0a99fa;9 color:#ffffff;10}11div.stButton > button:hover {12 background-color: #ffffff;13 color:#0a99fa;14 }15</style>""", unsafe_allow_html=True)16 17# Creating Session State Variable18if 'API_Key' not in st.session_state:19 st.session_state['API_Key'] = ''20 21st.title('๐ Vector Creator')22 23# Sidebar to capture the OpenAi API key24st.sidebar.title("๐๏ธ")25st.session_state['API_Key'] = st.sidebar.text_input("Paste in your OPENAI API key?", type="password")26st.sidebar.markdown('Vector Generator: Input some text to view its vector. Designed for my cloud Meetup as a demonstration of simple vectorization. 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')27 28# Captures User Inputs29prompt = st.text_input('Please add some text to vectorize', key="prompt")30 31submit = st.button("Generate a Vector for me")32 33if submit:34 35 if st.session_state['API_Key']:36 text_embedding = generate_vector(prompt, st.session_state['API_Key'])37 # Let's generate the script38 st.success('You are now in 1536 dimensional space, how does it feel?')39 40 # Display Title41 st.subheader("Vector:๐")42 st.write(text_embedding)43 44 45 else:46 st.error("Please provide your OpenAI API key in the left column.....")