# 1. 创建画像模板(CreateProfileSchema)
curl -X POST https://dashscope.aliyuncs.com/api/v2/apps/memory/profile_schemas \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"name": "用户基础画像",
"description": "包含年龄和兴趣的用户信息",
"attributes": [
{"name": "年龄", "description": "用户年龄"},
{"name": "爱好", "description": "用户的兴趣爱好"},
{"name": "职业", "description": "用户职业"}
]
}'
# 2. 添加对话并提取画像(AddMemory,传入上面返回的 profile_schema_id)
curl -X POST https://dashscope.aliyuncs.com/api/v2/apps/memory/add \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"user_id": "user_001",
"messages": [
{"role": "user", "content": "我今年28岁,是一名软件工程师。周末喜欢踢足球。"},
{"role": "assistant", "content": "很高兴认识你!"}
],
"profile_schema": "YOUR_SCHEMA_ID"
}'
# 3. 获取用户画像(GetUserProfile,等待3秒后执行)
curl -X GET "https://dashscope.aliyuncs.com/api/v2/apps/memory/profile_schemas/{YOUR_SCHEMA_ID}/user_profile?user_id=user_001" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json"