From 037d993578790575dea9a883f888f42216efe766 Mon Sep 17 00:00:00 2001 From: Chitra Kabirdoss <64376287+chitragans@users.noreply.github.com> Date: Sun, 12 May 2024 18:19:11 -0700 Subject: [PATCH] Update streamlit_app.py --- streamlit_app.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/streamlit_app.py b/streamlit_app.py index 3a8699f..bb506ad 100644 --- a/streamlit_app.py +++ b/streamlit_app.py @@ -1,5 +1,18 @@ import streamlit as st +from langchain.llms import OpenAI -st.title('🎈 App Name') +st.title('🦜🔗 Quickstart App') -st.write('Hello world!') +openai_api_key = st.sidebar.text_input('OpenAI API Key') + +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)