Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import openai
|
3 |
+
|
4 |
+
# Define your sophisticated prompts and other necessary components from your script
|
5 |
+
|
6 |
+
def generate_detailed_artifact(api_key, description, artifact_type):
|
7 |
+
"""
|
8 |
+
Interact with OpenAI using the provided API key to generate the artifact content.
|
9 |
+
"""
|
10 |
+
openai.api_key = api_key
|
11 |
+
# Your existing logic to generate artifact
|
12 |
+
|
13 |
+
st.title("AI-Enabled Project Artifact Generator")
|
14 |
+
|
15 |
+
# Use Streamlit's session state to remember the API key if it's already been entered
|
16 |
+
if 'api_key' not in st.session_state:
|
17 |
+
st.session_state.api_key = ''
|
18 |
+
|
19 |
+
api_key_input = st.text_input("Enter your OpenAI API Key", type="password", value=st.session_state.api_key)
|
20 |
+
|
21 |
+
if api_key_input:
|
22 |
+
st.session_state.api_key = api_key_input # Update session state with the new key
|
23 |
+
with st.form("artifact_generator"):
|
24 |
+
artifact_types = list(sophisticated_prompts.keys())
|
25 |
+
description = st.text_area("Enter Project Description", "Type your project description here...")
|
26 |
+
selected_artifact_types = st.multiselect("Select Artifact Types", artifact_types, default=artifact_types[0])
|
27 |
+
generate_button = st.form_submit_button("Generate Artifacts")
|
28 |
+
|
29 |
+
if generate_button and st.session_state.api_key:
|
30 |
+
tab_container = st.tabs([f"{artifact_type}" for artifact_type in selected_artifact_types])
|
31 |
+
|
32 |
+
for i, artifact_type in enumerate(selected_artifact_types):
|
33 |
+
artifact_content = generate_detailed_artifact(st.session_state.api_key, description, artifact_type)
|
34 |
+
|
35 |
+
with tab_container[i]:
|
36 |
+
st.markdown(artifact_content, unsafe_allow_html=True)
|
37 |
+
else:
|
38 |
+
st.warning("Please enter your OpenAI API key to use the app.")
|