File size: 3,805 Bytes
d8c5622
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 测试示例 - 验证用户输入是否被正确使用

## 如何测试

### 方法 1: 通过 Web 界面测试

1. 启动应用:
```bash
cd /Users/yufan_zhou/Documents/deeppersona/deeppersona-experience
python app.py
```

2. 在浏览器中打开 `http://localhost:7860`

3. 输入测试数据(例如):
   - **Age**: 28
   - **Gender**: Male
   - **Occupation**: Data Scientist
   - **City**: San Francisco
   - **Country**: USA
   - **Personal Values**: (留空,测试自动生成)
   - **Life Attitude**: "Curious and analytical"
   - **Life Story**: (留空,测试自动生成)
   - **Interests and Hobbies**: "Machine learning, hiking"

4. 点击 "Generate Character Profile"

5. **检查控制台输出**,应该看到类似:
```
Found existing user_profile.json, using preset inputs...
✓ Using user-provided age: 28
✓ Using user-provided gender: Male
✓ Using user-provided location: San Francisco, USA
✓ Using user-provided occupation: Data Scientist
✗ Personal values not provided, generated based on user inputs
✓ Using user-provided life attitude: Curious and analytical
✗ Life story not provided, generated based on user inputs
✓ Using user-provided interests: Machine learning, hiking
```

6. **检查生成的 Profile**,应该包含:
   - 年龄 28 岁
   - 性别 Male
   - 职业 Data Scientist
   - 地点 San Francisco, USA
   - 生活态度包含 "Curious and analytical"
   - 兴趣包含 "Machine learning" 和 "hiking"

### 方法 2: 通过命令行测试

1. 创建测试输入文件 `test_input.json`:
```json
{
  "basic_info": {
    "age": 25,
    "gender": "Female",
    "occupation": {
      "status": "Software Engineer"
    },
    "location": {
      "city": "Tokyo",
      "country": "Japan"
    }
  },
  "custom_values": {
    "personal_values": "Values innovation and teamwork",
    "life_attitude": "",
    "life_story": "",
    "interests_hobbies": "Coding, anime, gaming"
  }
}
```

2. 运行测试:
```bash
cd /Users/yufan_zhou/Documents/deeppersona/deeppersona-experience/generate_user_profile_final/code
python web_api_bridge.py --input test_input.json --attributes 200
```

3. **检查输出**,应该显示:
```
✓ Using user-provided age: 25
✓ Using user-provided gender: Female
✓ Using user-provided location: Tokyo, Japan
✓ Using user-provided occupation: Software Engineer
✓ Using user-provided personal values: Values innovation and teamwork
✗ Life attitude not provided, generated based on user inputs
✗ Life story not provided, generated based on user inputs
✓ Using user-provided interests: Coding, anime, gaming
```

## 验证要点

### ✅ 正确行为
1. 用户输入的字段显示 `✓ Using user-provided ...`
2. 未输入的字段显示 `✗ ... not provided, generated ...`
3. 生成的 profile 包含所有用户输入的内容
4. 未输入的字段基于已输入内容合理生成(不是完全随机)

### ❌ 错误行为(如果看到这些,说明修复失败)
1. 所有字段都显示 `✗ ... not provided, generated ...`(说明用户输入被忽略)
2. 用户输入的年龄、性别等与生成的 profile 不匹配
3. 生成的内容与用户输入完全无关

## 调试提示

如果测试失败,检查以下内容:

1. **检查 `user_profile.json` 是否正确保存**:
```bash
cat /Users/yufan_zhou/Documents/deeppersona/deeppersona-experience/generate_user_profile_final/output/user_profile.json
```

2. **检查控制台是否显示 "Found existing user_profile.json"**:
   - 如果没有,说明文件路径不对
   - 如果显示 "No existing user_profile.json found",说明文件没有被保存

3. **检查是否有错误信息**:
   - 查看完整的 traceback
   - 检查是否有 JSON 解析错误
   - 检查是否有字段类型不匹配的错误