ReqAssist / app.py
os1187's picture
Create app.py
376c7ad verified
raw
history blame
1.7 kB
import streamlit as st
import openai
# Define your sophisticated prompts and other necessary components from your script
def generate_detailed_artifact(api_key, description, artifact_type):
"""
Interact with OpenAI using the provided API key to generate the artifact content.
"""
openai.api_key = api_key
# Your existing logic to generate artifact
st.title("AI-Enabled Project Artifact Generator")
# Use Streamlit's session state to remember the API key if it's already been entered
if 'api_key' not in st.session_state:
st.session_state.api_key = ''
api_key_input = st.text_input("Enter your OpenAI API Key", type="password", value=st.session_state.api_key)
if api_key_input:
st.session_state.api_key = api_key_input # Update session state with the new key
with st.form("artifact_generator"):
artifact_types = list(sophisticated_prompts.keys())
description = st.text_area("Enter Project Description", "Type your project description here...")
selected_artifact_types = st.multiselect("Select Artifact Types", artifact_types, default=artifact_types[0])
generate_button = st.form_submit_button("Generate Artifacts")
if generate_button and st.session_state.api_key:
tab_container = st.tabs([f"{artifact_type}" for artifact_type in selected_artifact_types])
for i, artifact_type in enumerate(selected_artifact_types):
artifact_content = generate_detailed_artifact(st.session_state.api_key, description, artifact_type)
with tab_container[i]:
st.markdown(artifact_content, unsafe_allow_html=True)
else:
st.warning("Please enter your OpenAI API key to use the app.")