navhira commited on
Commit
c7e880a
Β·
1 Parent(s): 9176e30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -1,16 +1,18 @@
1
  import streamlit as st
 
2
 
3
- animal = st.form('my_animal')
4
 
5
- # This is writing directly to the main body. Since the form container is
6
- # defined above, this will appear below everything written in the form.
7
- sound = st.selectbox('Sounds like', ['meow','woof','squeak','tweet'])
8
 
9
- # These methods called on the form container, so they appear inside the form.
10
- submit = animal.form_submit_button(f'Say it with {sound}!')
11
- sentence = animal.text_input('Your sentence:', 'Where\'s the tuna?')
12
- say_it = sentence.rstrip('.,!?') + f', {sound}!'
13
- if submit:
14
- animal.subheader(say_it)
15
- else:
16
- animal.subheader(' ')
 
 
 
 
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)