lampongyuen commited on
Commit
d490e74
Β·
1 Parent(s): 3ea4cc0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain.llms import OpenAI
3
+
4
+ st.title('πŸ¦œπŸ”— Quickstart App')
5
+
6
+ openai_api_key = st.sidebar.text_input('OpenAI API Key')
7
+
8
+ def generate_response(input_text):
9
+ llm = OpenAI(temperature=0.7, openai_api_key=openai_api_key)
10
+ st.info(llm(input_text))
11
+
12
+ with st.form('my_form'):
13
+ text = st.text_area('Enter text:', 'What are the three key pieces of advice for learning how to code?')
14
+ submitted = st.form_submit_button('Submit')
15
+ if not openai_api_key.startswith('sk-'):
16
+ st.warning('Please enter your OpenAI API key!', icon='⚠')
17
+ if submitted and openai_api_key.startswith('sk-'):
18
+ generate_response(text)