A multi-agent system for generating realistic clinical case studies for training purposes. The system uses a series of specialized agents to process client information and generate comprehensive case studies with cognitive-behavioral therapy (CBT) elements.
The system consists of four main agents:
- Preprocessing Agent: Structures raw client input data
- Case Generator Agent: Enriches the case with cognitive patterns and consequences
- Narrative Agent: Creates a cohesive first-person narrative
- Final Review Agent: Combines all outputs into a final case study
- Web-based interface for data input
- Step-by-step case generation process
- JSON-based data structure
- Real-time processing and display
- CBT-focused case formulation
IMPORTANT: Server for 'intermediate' case generator work on 3001 port, base case generator work on 3000 port.
- Clone the repository and go to the backend folder:
cd backend - Install dependencies:
pnpm install
- Create a
.envfile in the root directory with your OpenAI API key:ANTHROPIC_API_KEY=your_api_key_here
-
Start the server:
node server.js (3000 port) node case_generator_server.js (3001 port)
-
Open
frontend/case_generator.htmlin your browser
i recomend use httpserver for frontend:
npx http-server- Fill in the client information form and submit to generate a case study
- POST
/api/preprocess: Processes raw client data - POST
/api/generate-case: Generates enriched case data - POST
/api/generate-narrative: Creates narrative description - POST
/api/finalize-case: Produces final case study
{
"client_profile": {
"age": 35,
"gender": "Female",
"occupation": "Software Engineer"
},
"presenting_problem": {
"symptoms": [
"persistent sadness",
"loss of interest",
"fatigue"
],
"trigger_event": "Recent breakup with a long-term partner"
}
}{
"client_profile": { ... },
"presenting_problem": { ... },
"cognitive_patterns": {
"automatic_thoughts": [ ... ],
"core_beliefs": [ ... ]
},
"consequences": {
"emotional": [ ... ],
"behavioral": [ ... ]
},
"client_narrative": "..."
}- The system requires an OpenAI API key
- CORS is enabled for local development
- Input validation is performed at multiple stages
- Sensitive clinical data should be handled according to relevant privacy regulations
The project uses:
- Express.js for the backend
- Anthropic Claude Haiku for text generation
- Bootstrap for the frontend UI
- Vanilla JavaScript for frontend logic
MIT License