File size: 1,550 Bytes
a7013cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6152ddf
a7013cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from utils import generate_vector

# Applying Styling
st.markdown("""
<style>
div.stButton > button:first-child {
    background-color: #0a99fa;
    color:#ffffff;
}
div.stButton > button:hover {
    background-color: #ffffff;
    color:#0a99fa;
    }
</style>""", unsafe_allow_html=True)

# Creating Session State Variable
if 'API_Key' not in st.session_state:
    st.session_state['API_Key'] = ''

st.title('πŸ“ Vector Creator')

# Sidebar to capture the OpenAi API key
st.sidebar.title("πŸ—οΈ")
st.session_state['API_Key'] = st.sidebar.text_input("Paste in your OPENAI API key?", type="password")
st.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')

# Captures User Inputs
prompt = st.text_input('Please add some text to vectorize', key="prompt")

submit = st.button("Generate a Vector for me")

if submit:

    if st.session_state['API_Key']:
        text_embedding = generate_vector(prompt, st.session_state['API_Key'])
        # Let's generate the script
        st.success('You are now in 1536 dimensional space, how does it feel?')

        # Display Title
        st.subheader("Vector:πŸ”")
        st.write(text_embedding)


    else:
        st.error("Please provide your OpenAI API key in the left column.....")