streamlit_test / app.py
navhira's picture
Update app.py
e5614a6
raw
history blame
721 Bytes
pip install streamlit openai langchain
import streamlit as st
from langchain.llms import OpenAI
st.title('πŸ¦œπŸ”— Quickstart App')
openai_api_key = st.sidebar.text_input('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')
def generate_response(input_text):
llm = OpenAI(temperature=0.7, openai_api_key=openai_api_key)
st.info(llm(input_text))
with st.form('my_form'):
text = st.text_area('Enter text:', 'What are the three key pieces of advice for learning how to code?')
submitted = st.form_submit_button('Submit')
if not openai_api_key.startswith('sk-'):
st.warning('Please enter your OpenAI API key!', icon='⚠')
if submitted and openai_api_key.startswith('sk-'):
generate_response(text)