Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

thinking-hats-ai: Python package implementing six thinking hats prompting

Package PyPI Latest Release PyPI - Downloads

What is it?

thinking-hats-ai is a Python package that facilitates idea generation by following Edward de Bono's Six Thinking Hats methodology from his Book. It enables you to generate ideas by selecting one of the six hats and lets you choose one of the implemented prompting technique to follow while generating the idea.

Table of Contents

Use of Package

Example script

This example uses the CHAIN_OF_THOUGHT prompting techniques and the BLACK hat for the personality. It also uses developer mode to log the interaction in a separate file.

### Import package
from thinking_hats_ai import BrainstormingSession, Technique, Hat, BrainstormingInput

### Create session
session = BrainstormingSession('YOUR-OPENAI-API-KEY')
session.dev = True # Activate dev mode

### Define current status
brainstormingInput = BrainstormingInput(
    question = 'How could you make students come to class more often even though there are podcasts provided for each lecture?',
    ideas=[
        "Implement an interactive class participation system with incentives",
        "Extra credits or digital badges, encouraging students to attend and engage actively",
        "Offer exclusive in-class activities or discussions that are not available in the podcasts",
        "Create a social media group for students to share their experiences and insights from attending class",
        "Organize regular contests or challenges related to class content, with prizes for participants",
        "Provide a comfortable and engaging classroom environment with refreshments and seating arrangements",
        "Incorporate gamification elements into the class structure, such as quizzes or team-based activities",
    ],
    response_length='5 bullet points'
)

### Generate output
response = session.generate_idea(
    Technique.CHAIN_OF_THOUGHT,
    Hat.BLACK,
    brainstormingInput
)

### Print output
print(response)

Hats

The different hats act as a predefined persona according to Edward de Bono's book about the six thinking hats in brainstorming. You can select which persona should be used for your instance.

Hat Role
WHITE The White Hat represents neutrality and objectivity, focusing on gathering facts, identifying information gaps, and evaluating existing knowledge to ensure all reasoning is grounded in evidence and logic.
GREEN The Green Hat represents creativity and innovation, focusing on generating new ideas, exploring alternatives, and proposing improvements to existing concepts to encourage original and unconventional thinking.
BLACK The Black Hat represents critical judgment and caution, focusing on identifying potential risks, weaknesses, and negative outcomes of ideas to ensure they are practical and safe.
YELLOW The Yellow Hat represents optimism and positivity, focusing on identifying the benefits, strengths, and potential value of ideas to highlight why they are worth pursuing.
BLUE The Blue Hat represents control, organization, and overview, guiding the thinking process, setting objectives, managing the discussion, and ensuring that the Six Thinking Hats method is followed effectively.
RED The Red Hat represents emotions, intuition, and gut feelings, allowing participants to express their instincts or emotional reactions to ideas without the need for justification or logic.

source: Book

Prompting techniques

The different prompting techniques help to analyse different approaches of idea generation for each hat. While implementing, we analyzed which of the techniques work best for which hat.

Technique Explanation
CHAIN_OF_THOUGHT The Chain of Thought technique guides the model to reason step-by-step, leveraging its advanced reasoning capabilities to improve coherence and depth in idea generation.
CHAIN_OF_VERIFICATION The Chain of Verification technique refines ideas by chaining prompts, generating verification questions, and analyzing responses.
CHAINING The Chaining technique builds a structured process: first understanding the thinking hat, then applying its perspective to the brainstorming context, and finally refining the response to ensure alignment.
CONTRASTIVE_PROMPTING The Contrastive Prompting technique uses examples of good and bad responses to guide the agent towards an optimal output.
EMOTION_PROMPT The EmotionPrompt technique enhances model performance by embedding emotional stimuli in prompts, encouraging more engaged, human-like, and context-aware responses.
FEW_SHOT The Few Shot technique uses example-based prompting by first generating three example responses from the hat's perspective, then applying these patterns to produce a final, guided response.
MULTI_AGENT The Multi-Agent technique involves multiple agents collaborating on a topic before converging on a refined final output.
PERSONA_PATTERN The Persona Pattern technique generates ideas by adopting predefined persona, offering unique perspective and goals.
REACT The ReAct (Reason and Act) technique combines reasoning and action by allowing models to interleave thought processes with tool use, enabling more accurate and interactive problem-solving.
SYSTEM_2_ATTENTION The System 2 Attention technique introduces a two-step prompting process: first filtering and organizing brainstorming input, then using this optimized context to generate higher-quality ideas.
TAKE_A_STEP_BACK The Take-a-Step-Back technique adds a follow-up question prompting the model to reflect on its initial reasoning before giving a final answer.
ZERO_SHOT_COT The Zero-shot Chain-of-Thought technique guides the model to reason step-by-step, breaking down complex problems into intermediate steps for improved accuracy and transparency.

Brainstorming-input

The instance of BrainstormingInput allows you to pass the brainstorming question, ideasand response_length to the generation of an idea.

Variable Name Explanation
question This variable takes a string, the question that was asked in the brainstorming session
ideas This variable takes a list of strings where each string is a idea from the brainstorming session
response_length This variable takes a string which will control the length of the answer. You can say "10 sentences" but also things like "similar to the other ideas". It should fit the sentence: Provide a response with a length of {response_length}.

Developer mode

The developer mode is used to log the in/outputs of the api calls. A log folder and log files will be created when executing a Script with activated developer mode. This was implemented for prompt engineering purposes and help to analyse the history of all API calls made.

It can be activated by setting the dev attribute to True (default False).

instance.dev = True

Installation

This package is available through the Python Package Index (PyPI).

pip install thinking-hats-ai

Dependencies

Background

The implementation of thinking-hats-ai started at UZH as a part of three bachelors theses.

Creators


Go to Top

Metadata

Release files for thinking-hats-ai 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thinking-hats-ai 1.2.1
File Size Uploaded
thinking_hats_ai-1.2.1.tar.gz 145.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for thinking-hats-ai 1.2.1
File Interpreter ABI Platform
thinking_hats_ai-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 184.6 kB

Release files / thinking_hats_ai-1.2.1.tar.gz

Download URL thinking_hats_ai-1.2.1.tar.gz
Size 145.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e76066b47e41083021993f6cfda385d912a57fb4ff8ca3a6b90084f618aa3b33
BLAKE2b-256 checksum
How to use checksums
fb9296e2f5cd5ff51eaca3c0a3c97294c1ce16336fe5e4393b54ac925dfd67bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / thinking_hats_ai-1.2.1-py3-none-any.whl

Download URL thinking_hats_ai-1.2.1-py3-none-any.whl
Size 38.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fe25e97057f1e8d90c28f5d39005ca0bd8a2b076691b5bc6ce7dc3df6f5a4e3
BLAKE2b-256 checksum
How to use checksums
722e92d201cc07d5638bfcb80cfca3554651fc1b1582171e27d0ae3b95a609d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page