os1187 commited on
Commit
7c25ff9
1 Parent(s): 376c7ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -24
app.py CHANGED
@@ -1,38 +1,56 @@
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.")
 
1
  import streamlit as st
2
  import openai
3
 
4
+ # Assuming your OpenAI API key is set in an environment variable or entered in the app
5
+ # For the app, we'll ask the user to input it directly for demonstration purposes
6
 
7
  def generate_detailed_artifact(api_key, description, artifact_type):
8
  """
9
+ Generate a detailed and sophisticated artifact for software development projects.
10
  """
11
+ sophisticated_prompts = {
12
+ "Strategic Alignment Report": "Craft a comprehensive report that articulates the alignment of AI initiatives with the organization's long-term strategic goals, demonstrating how AI can be leveraged for strategic advantage.",
13
+ "Enhanced Process Maps": "Develop enhanced process maps indicating AI integration points. Detail the current versus future state of processes, specifying where AI brings value.",
14
+ "AI Impact Forecast": "Generate a forecast report that assesses the potential impacts of AI on business processes, scalability of solutions, and a framework for measuring and monitoring these impacts.",
15
+ "Stakeholder Engagement Plan": "Create a detailed stakeholder engagement plan that lists all stakeholders, their concerns, expectations, and strategies for managing the cultural shift towards AI adoption.",
16
+ "AI Risk Mitigation Strategy": "Construct a comprehensive risk mitigation strategy document outlining the potential risks of AI integration and detailed plans for addressing these risks.",
17
+ "Cost-Benefit Analysis Document": "Produce a cost-benefit analysis document for AI projects, detailing investment requirements, financial benefits, total cost of ownership, and prioritization of initiatives based on financial metrics.",
18
+ "AI Prototyping Strategy": "Outline a strategic plan for prototyping AI initiatives, including the prototyping phases, success metrics, resource needs, and a feedback incorporation mechanism.",
19
+ "Change Management Framework": "Develop a change management framework that analyzes the impact of AI, provides a detailed change plan, identifies training needs, and establishes clear communication strategies.",
20
+ "AI Monitoring and Review Framework": "Design a continuous AI monitoring and evaluation framework that details the KPIs, integration with BI systems, and the periodic review process for AI initiatives.",
21
+ "AI Roadmap and Action Plan": "Synthesize a strategic AI roadmap and action plan document based on workshop findings, assigning responsibilities and deadlines for the completion of action items."
22
+ }
23
+
24
+ prompt = sophisticated_prompts.get(artifact_type, "Generate a detailed document section:") + "\n" + description
25
+
26
+ try:
27
+ openai.api_key = api_key
28
+ response = openai.Completion.create(
29
+ model="gpt-4", # Adjust model as necessary
30
+ prompt=prompt,
31
+ temperature=0.5,
32
+ max_tokens=1024,
33
+ top_p=1.0,
34
+ frequency_penalty=0.0,
35
+ presence_penalty=0.0
36
+ )
37
+ return response.choices[0].text.strip()
38
+ except Exception as e:
39
+ return f"An error occurred: {str(e)}"
40
 
41
  st.title("AI-Enabled Project Artifact Generator")
42
 
43
+ api_key = st.text_input("Enter your OpenAI API key", type="password")
 
 
44
 
45
+ artifact_type = st.selectbox("Select Artifact Type", list(sophisticated_prompts.keys()))
46
 
47
+ description = st.text_area("Project Description", "Enter your project description here.")
 
 
 
 
 
 
48
 
49
+ if st.button("Generate Artifact"):
50
+ if api_key and description and artifact_type:
51
+ generated_artifact = generate_detailed_artifact(api_key, description, artifact_type)
52
+ st.markdown("## Generated Artifact")
53
+ st.write(generated_artifact)
54
+ else:
55
+ st.error("Please fill out all fields.")
56