Spaces:
Running
Running
File size: 5,219 Bytes
974c435 5d7e9a5 |
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
---
title: Mbti Pocketflow
emoji: π₯
colorFrom: pink
colorTo: gray
sdk: gradio
sdk_version: 5.38.2
app_file: app.py
pinned: false
short_description: PocketFlow application for conducting Myers-Briggs + llm
---
# MBTI Personality Questionnaire
A PocketFlow-based application for conducting Myers-Briggs Type Indicator (MBTI) personality assessments with both traditional scoring and AI analysis.
## Features
- **20/40/60-question MBTI questionnaire** with selectable length for accuracy
- **Traditional scoring algorithm** for baseline personality type determination
- **AI-powered analysis** using LLM for detailed personality insights with question references
- **Interactive Gradio web interface** with auto-save and progress tracking
- **HTML report generation** with clickable question references and comprehensive analysis
- **Data export/import** for saving and resuming questionnaires
- **CLI and test modes** for different use cases
## Project Structure
```
/mbt/
βββ utils/
β βββ call_llm.py # LLM integration (Gemini)
β βββ questionnaire.py # Question sets (20/40/60) and loading/saving
β βββ mbti_scoring.py # Traditional MBTI scoring
β βββ report_generator.py # HTML report generation with markdown support
β βββ test_data.py # Test data generation
βββ nodes.py # PocketFlow nodes (LoadQuestionnaire, LLMAnalysis, etc.)
βββ flow.py # PocketFlow flow definition
βββ app.py # **Main Gradio web interface with LLM**
βββ pf_cli.py # PocketFlow CLI interface
βββ requirements.txt # Dependencies
```
## Quick Start
### 1. Web Interface (Recommended)
```bash
# Install dependencies
pip install -r requirements.txt
# Set up Gemini API key
export GEMINI_API_KEY="your-api-key-here"
# Or on Windows:
set GEMINI_API_KEY=your-api-key-here
# Run Gradio web interface
python app.py
```
Then open http://127.0.0.1:7860 in your browser.
### 2. Command Line Interface
```bash
# Run CLI questionnaire
python pf_cli.py
# Run with test data
python pf_cli.py --test --test-type INTJ
# Import previous questionnaire
python pf_cli.py --import-file questionnaire.json
```
## Usage Examples
### Gradio Web Interface
```bash
python app.py
```
- **Interactive web interface** at http://127.0.0.1:7860
- **Question length selection** (20/40/60 questions)
- **Auto-save responses** as you navigate
- **Progress tracking** and export functionality
- **AI analysis** with clickable question references
- **HTML report generation** with comprehensive insights
- **Load/save questionnaires** for resuming later
### Command Line Interface
```bash
python pf_cli.py
```
- **Complete PocketFlow architecture**
- **Traditional scoring** with optional LLM analysis
- **Automatic report generation**
- **Data import/export** in JSON format
### Test Modes
```bash
# CLI test with specific MBTI type
python pf_cli.py --test --test-type ENFP
```
### Import/Export
```bash
# Export: Questionnaire data automatically saved as:
# mbti_questionnaire_pf_partial_[COUNT]q_[TIMESTAMP].json
# Import: Load previous questionnaire
python pf_cli.py --import-file questionnaire.json
```
## MBTI Types Supported
The application recognizes all 16 MBTI personality types:
**Analysts:** INTJ, INTP, ENTJ, ENTP
**Diplomats:** INFJ, INFP, ENFJ, ENFP
**Sentinels:** ISTJ, ISFJ, ESTJ, ESFJ
**Explorers:** ISTP, ISFP, ESTP, ESFP
## Key Features
### Question Sets
- **20 questions:** Quick assessment (5 per dimension)
- **40 questions:** Balanced assessment (10 per dimension)
- **60 questions:** Comprehensive assessment (15 per dimension)
### AI Analysis
- **Question-specific insights** with clickable references like [Q1](#Q1)
- **Out-of-character response detection** and explanations
- **Evidence-based analysis** citing specific question responses
- **Behavioral pattern identification**
- **Strengths and growth areas** based on actual responses
### Web Interface Features
- **Auto-save** responses on navigation
- **Progress tracking** with completion indicators
- **Export progress** at any time (partial questionnaires)
- **Load previous sessions** to continue where you left off
- **Immediate download** of reports and data
## Development
### Adding New Features
2. Implement utility functions in `utils/`
3. Create or modify nodes in `nodes.py`
4. Update flow in `flow.py`
5. Test with CLI and web interface
## Dependencies
**Required:**
- Python 3.8+
- gradio>=4.0.0 (web interface)
- google-genai>=0.3.0 (LLM analysis)
- beautifulsoup4 (HTML parsing)
- markdown (report generation)
**Optional:**
- pydantic (enhanced data validation)
See `requirements.txt` for complete list.
## File Overview
- **`gradio_pf_llm.py`** - Main web interface with full LLM analysis
- **`pf_cli.py`** - Command line interface using PocketFlow architecture
- **`nodes.py`** - PocketFlow node implementations
- **`flow.py`** - PocketFlow pipeline definition
- **`utils/`** - Core utility functions (questionnaire, scoring, reports, LLM)
## License
This project follows PocketFlow's open-source approach for educational and research purposes.
|