import streamlit as st import openai import os # Get OpenAI API key from Secrets openai.api_key = st.secrets["OPENAI_API_KEY"] #st.secrets["OPENAI_API_KEY"] #os.environ.get('OPENAI_API_KEY') # Define function to generate response to email def generate_response(email_text): # Create prompt prompt = f"I am sharing an email with you. Please generate a response to this email and be flattering of the sender, but assume I do not have a lot of time to meet with people.\n\n{email_text}\n\nYour response: " # Generate response response = openai.Completion.create( engine="text-davinci-003", prompt=prompt, max_tokens=1024, n=1, stop=None, temperature=0.7 # Add additional parameters here, such as prompt_id, file, or codify ) # Return response return response.choices[0].text # Create Streamlit interface st.title("Email Response Generator") # Input email text email_text = st.text_area("Enter email text", height = 200) # Generate response if email_text: response = generate_response(email_text) st.write("Response:") st.write(response) # Display interface st.stop()