CoolFace
Apppublic

roddomsatish/VectorEmbeddings

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py47 linesDownload Raw Back to root
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'] = 'ABC'26#st.sidebar.text_input("Paste in your key, even ABC will be fine?", type="password")27st.sidebar.markdown('Vector Generator: Input some text to view its vector.')28 29# Captures User Inputs30prompt = st.text_input('Please add some text to vectorize', key="prompt")31 32submit = st.button("Generate a Vector for me")33 34if submit:35 36    if st.session_state['API_Key']:37        text_embedding = generate_vector(prompt, st.session_state['API_Key'])38        # Let's generate the script39        st.success('You are now in 384 dimensional space, how does it feel, while OpenAI will give 1536 dimensional space?')40 41        # Display Title42        st.subheader("Vector:๐Ÿ”")43        st.write(text_embedding)44 45 46    else:47        st.error("Please provide your OpenAI API key in the left column.....")