File size: 885 Bytes
4accdd7 40e3082 4accdd7 82dc897 4accdd7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import streamlit as st
#from langchain.llms import OpenAI
from langchain_community.llms import OpenAI
st.title("ππ Quickstart App")
# Get the user's OpenAI API key
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
# Define a function to generate LLM responses
def generate_response(input_text):
llm = OpenAI(temperature=0.7, openai_api_key=openai_api_key)
st.info(llm(input_text))
# Create a text input area for user prompts
with st.form("my_form"):
text = st.text_area("Enter text:", "What are the three character traits that a good developer should have?")
submitted = st.form_submit_button("Submit")
# Validate the API key and generate a response
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)
|