File size: 1,698 Bytes
376c7ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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.")