Skip to content

Commit 34572c4

Browse files
committed
2 parents 945d38a + b0c6a43 commit 34572c4

8 files changed

Lines changed: 110 additions & 18 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> A unified hub to create, simulate, and evaluate methods for patient/client simulation.
44
5-
📚 **[Documentation](https://sahandsabour.github.io/PatientHub/)** | 🚀 **[Quick Start](#quick-start)** | 📦 **[Supported Agents](#3-supported-agents)**
5+
📚 **[Documentation](https://sahandfer.github.io/PatientHub/)** | 🚀 **[Quick Start](#quick-start)** | 📦 **[Supported Agents](#3-supported-agents)**
66

77
## Quick Start
88

data/prompts/therapist/psyche.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
en:
2+
sys_prompt: |
3+
You are an experienced psychiatrist conducting an initial interview with a new patient. Your goal is to gather comprehensive information about the patient’s mental health, symptoms, background, and potential diagnoses. Use a combination of open-ended questions, specific inquiries, and follow-up questions to explore the patient’s situation in depth. Pay attention to both verbal and non-verbal cues, and use your expertise to guide the conversation towards areas that may be particularly relevant for diagnosis.
4+
5+
The following aspects need to be assessed in the patient: Chief complaint, Present illness, Symptoms, Alleviating factors, Exacerbating factors, Symptom duration, Triggering factors (why the patient decided to visit the hospital today), Stressors, Family history (including diagnoses and substance use), Current family structure, Suicidal ideation, Suicide risk, Self-harming behavior risk, Homicide risk, Suicidal plans, Suicide attempts, Mood, Affect, Verbal productivity, Insight, Perception, Thought process, Thought content, Spontaneity, Social judgment, and Reliability.
6+
7+
When starting the conversation, begin with exactly these words: "Hello, I’m Dr. Minsoo Kim, what’s your name?". Ask questions one at a time, at most.
8+
9+
After the interview with the patient is complete, someone will come to ask you about the patient. As an experienced psychiatrist, use appropriate reasoning, your professional judgment, and the information you’ve gathered during the interview to answer their questions. If you cannot determine something even with appropriate reasoning and your expertise, respond with "I don’t know".
10+
11+
zh:
12+
sys_prompt: |
13+
你是一名经验丰富的精神科医生,正在对一位新患者进行初诊访谈。你的目标是全面收集患者的心理健康状况、症状、背景以及可能的诊断信息。请结合开放式提问、具体询问与追问,深入探索患者的处境。注意患者的言语与非言语线索,并运用你的专业经验引导对话,聚焦于对诊断可能尤为相关的领域。
14+
15+
需要评估的方面包括:主诉、现病史、症状、缓解因素、加重因素、症状持续时间、诱发因素(为什么患者今天决定来就诊)、压力源、家族史(包括相关诊断与物质使用)、当前家庭结构、自杀意念、自杀风险、自伤行为风险、他杀风险、自杀计划、自杀尝试、心境、情感、言语产出、自知力、知觉、思维过程、思维内容、自发性、社会判断力以及可靠性。
16+
17+
开始对话时,请以以下开场白开始:"您好,我是金敏洙医生, 请问您叫什么?"。每次最多只问一个问题。
18+
19+
当你与患者的访谈结束后,会有人来向你询问患者情况。作为一名经验丰富的精神科医生,请运用恰当的推理、你的专业判断以及访谈中收集到的信息来回答他们的问题。如果即使运用恰当的推理与专业经验仍无法确定某件事,请回答:"我不知道"。

docs/docs/getting-started/installation.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ sidebar_position: 1
1313

1414
```bash
1515
# Clone the repository
16-
git clone https://github.com/Sahandfer/Patient-Simulation.git
17-
cd Patient-Simulation
16+
git clone https://github.com/Sahandfer/PatientHub.git
17+
cd PatientHub
1818

1919
# Install dependencies
2020
uv sync
@@ -27,8 +27,8 @@ source .venv/bin/activate
2727

2828
```bash
2929
# Clone the repository
30-
git clone https://github.com/Sahandfer/Patient-Simulation.git
31-
cd Patient-Simulation
30+
git clone https://github.com/Sahandfer/PatientHub.git
31+
cd PatientHub
3232

3333
# Create virtual environment
3434
python -m venv .venv
@@ -39,16 +39,44 @@ pip install -e .
3939
```
4040

4141
## Configuration
42-
43-
Create a `.env` file in the project root:
42+
Create a `.env` file in the project root:
43+
### Cloud Models
4444

4545
```bash
4646
OPENAI_API_KEY=<your API key>
4747
OPENAI_BASE_URL=https://api.openai.com
4848
```
4949

5050
:::tip Using Other Providers
51-
PatientHub supports OpenAI, HuggingFace, and local models. See [Configuration](/docs/getting-started/configuration) for details.
51+
PatientHub supports cloud and local models. See [Configuration](/docs/getting-started/configuration) for details.
52+
:::
53+
54+
### Local Models via vLLM
55+
Our recommended setup for local models is to run a vLLM (or OpenAI-compatible) server on a machine/process, then have PatientHub call it over HTTP via `LOCAL_BASE_URL`.
56+
57+
1) Install vLLM on the serving machine (GPU recommended):
58+
59+
```bash
60+
pip install -U vllm
61+
```
62+
63+
2) Serve a model with the OpenAI-compatible endpoint (example):
64+
65+
```bash
66+
vllm serve Qwen/Qwen2.5-7B-Instruct --host 0.0.0.0 --port 8000
67+
```
68+
69+
3) Point PatientHub to the server in your `.env`:
70+
71+
```bash
72+
LOCAL_BASE_URL=http://<SERVER_HOST>:8000/v1
73+
LOCAL_API_KEY=EMPTY
74+
```
75+
76+
Then set your config to use `model_type=LOCAL` and `model_name` to the model name exposed by your vLLM server.
77+
78+
:::note vLLM fails to start
79+
it’s usually a CUDA/driver mismatch on the serving machine—check your NVIDIA driver/CUDA runtime and use a vLLM version compatible with your environment.
5280
:::
5381

5482
## Verify Installation
@@ -85,10 +113,3 @@ Ensure you've activated the virtual environment:
85113
```bash
86114
source .venv/bin/activate
87115
```
88-
89-
**CUDA/GPU issues:**
90-
For local models, ensure PyTorch is installed with CUDA support:
91-
92-
```bash
93-
pip install torch --index-url https://download.pytorch.org/whl/cu118
94-
```

docs/docs/intro.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ config = OmegaConf.create({
3030
'temperature': 0.7,
3131
'max_tokens': 1024,
3232
'max_retries': 3,
33+
'patient_type': 'upset',
3334
'data_path': 'data/characters/PatientPsi.json',
3435
'data_idx': 0,
3536
})

docs/src/pages/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function QuickStart() {
4747
<pre className={styles.codeBlock}>
4848
<code>
4949
{`# Clone the repository
50-
git clone https://github.com/Sahandfer/Patient-Simulation.git
51-
cd Patient-Simulation
50+
git clone https://github.com/Sahandfer/PatientHub.git
51+
cd PatientHub
5252
5353
# Install dependencies
5454
uv sync

patienthub/therapists/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from .user import UserTherapist, UserTherapistConfig
33
from .CBT import CBTTherapist, CBTTherapistConfig
44
from .bad import BadTherapist, BadTherapistConfig
5+
from .psyche import PsycheTherapist, PsycheTherapistConfig
6+
57

68

79
from omegaconf import DictConfig
@@ -12,6 +14,7 @@
1214
"user": UserTherapist,
1315
"CBT": CBTTherapist,
1416
"bad": BadTherapist,
17+
"psyche": PsycheTherapist,
1518
}
1619

1720
# Registry of therapist configs (for Hydra registration)
@@ -20,6 +23,7 @@
2023
"user": UserTherapistConfig,
2124
"CBT": CBTTherapistConfig,
2225
"bad": BadTherapistConfig,
26+
"psyche": PsycheTherapistConfig,
2327
}
2428

2529

patienthub/therapists/psyche.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from typing import Dict, List
2+
from omegaconf import DictConfig
3+
from dataclasses import dataclass
4+
5+
from patienthub.base import ChatAgent
6+
from patienthub.configs import APIModelConfig
7+
from patienthub.utils import load_prompts, load_json, get_chat_model
8+
9+
@dataclass
10+
class PsycheTherapistConfig(APIModelConfig):
11+
"""
12+
Configuration for the PsycheTherapist agent.
13+
"""
14+
agent_type: str = "psyche"
15+
16+
class PsycheTherapist(ChatAgent):
17+
def __init__(self, configs: DictConfig):
18+
self.configs = configs
19+
20+
self.name = "Dr. Minsoo Kim"
21+
22+
self.chat_model = get_chat_model(configs)
23+
self.prompts = load_prompts(
24+
role="therapist", agent_type="psyche", lang=configs.lang
25+
)
26+
self.build_sys_prompt()
27+
28+
def build_sys_prompt(self):
29+
self.messages = [{"role": "system", "content": self.prompts["sys_prompt"].render()}]
30+
31+
def set_client(self, client, prev_sessions: List[Dict[str, str] | None] = []):
32+
self.client = client.get("name", "client")
33+
34+
def generate_response(self, msg: str):
35+
self.messages.append({"role": "user", "content": msg})
36+
res = self.chat_model.generate(self.messages)
37+
self.messages.append({"role": "assistant", "content": res.content})
38+
39+
return res
40+
41+
def reset(self):
42+
self.build_sys_prompt()
43+
self.client = None

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ dev = [
2424
"jupyter>=1.1.1",
2525
"ipykernel>=7.0.1",
2626
"chainlit>=2.8.3",
27-
]
27+
]
28+
29+
[tool.setuptools.packages.find]
30+
include = ["patienthub*"]
31+
exclude = ["data*"]

0 commit comments

Comments
 (0)