Spaces:
Runtime error
Runtime error
| 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.....") |