Team Ai
Apppublic

eaglelandsonce/simplevectorization

sourceHugging Faceupdated 3y agoView on Hugging Face
10likes
app.py46 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'] = 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.....")