-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.py
83 lines (73 loc) · 4.09 KB
/
app.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import streamlit as st
from methods.big_mind_mapping import bmm
from methods.reverse_brainstorm import rb
from methods.role_storming import rs
from methods.scamper import sc
from methods.six_hats import sh
from methods.starburtsting import sb
from langchain_openai import ChatOpenAI
# Make the layout wide for better display
st.set_page_config(page_title="🧠 Brainstormers", layout="wide")
# Sidebar for API key input
st.sidebar.title("⚙️ Settings")
api_key = st.sidebar.text_input("Enter your OpenAI API Key:", type="password")
# Check if API key is provided
if api_key:
# Initialize the OpenAI model with the API key
llm = ChatOpenAI(model="gpt-4o-mini", api_key=api_key)
# App title and description
st.title("🧠 Brainstormers")
st.write("Welcome! Choose a brainstorming mode to start generating ideas for your project.")
# Define the brainstorming modes, their corresponding functions, and descriptions
modes = {
"Big Mind Mapping": {
"function": lambda query: bmm(query, llm),
"description": "This involves creating a tree of ideas to explore the maximum amount of ideas in a very wide area. "
"This is perfect when you are lost and want to gather the maximum number of ideas."
},
"Reverse Brainstorming": {
"function": lambda query: rb(query, llm),
"description": "Instead of focusing on solutions, this technique involves identifying ways to cause a problem or "
"achieve the opposite effect. Perfect for spotting potential issues and coming up with innovative solutions."
},
"Role Storming": {
"function": lambda query: rs(query, llm),
"description": "Involves adopting the perspective of someone else to generate ideas. Great for gathering insights from different viewpoints."
},
"SCAMPER": {
"function": lambda query: sc(query, llm), # Pass `llm` to `sc`
"description": "SCAMPER stands for Substitute, Combine, Adapt, Modify, Put to another use, Eliminate, and Reverse. "
"This method encourages thinking from multiple perspectives to generate diverse ideas."
},
"Six Thinking Hats": {
"function": lambda query: sh(query, llm),
"description": "This method, developed by Edward de Bono, looks at a problem from six different perspectives: "
"White (Data), Red (Emotions), Black (Risks), Yellow (Benefits), Green (Creativity), and Blue (Process management)."
},
"Starbursting": {
"function": lambda query: sb(query, llm),
"description": "Focuses on generating questions rather than answers using the 5 W's and 1 H (Who, What, Where, When, Why, How). "
"Ideal for comprehensive topic exploration."
}
}
# Mode selection
mode_choice = st.selectbox("Select a brainstorming mode:", list(modes.keys()))
# Display the description of the selected mode
if mode_choice:
st.write(f"**Mode selected:** {mode_choice}")
st.write(modes[mode_choice]["description"]) # Display mode description
# User input for idea description
user_query = st.text_area("Describe your idea in detail to get started:",
"I want idea projects using LangChain that involves AI Agents and that solves social problems.")
# Button to start the brainstorming process
if st.button("Generate Ideas"):
# Display a loading message
with st.spinner("Generating ideas, please wait..."):
# Call the function for the selected mode
result = modes[mode_choice]["function"](user_query)
# Display the result in markdown format
st.markdown(result)
else:
# Display a message asking for the API key
st.title("🧠 Brainstormers")
st.write("Unlock creative brainstorming methods like Big Mind Mapping, SCAMPER, and Role Storming to spark new ideas. Just add your OpenAI API Key in the sidebar to get started!")