Get User Profile
Updated at:
Get the profile attributes of a specified user
Gets the profile attributes of a specified user. Profile extraction is asynchronous. After calling AddMemory, the first query may not contain attribute values, so retry according to your application's retry policy.
NoteIf all returned attribute values are empty, verify that AddMemory was called with the same profile_schema. Without that parameter, profile extraction is not triggered.
Endpoint
GET
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/profile_schemas/{profile_schema_id}/user_profileReplace {WorkspaceId} with your actual workspace ID.
Path parameters
profile_schema_idstringRequiredProfile schema ID
Query parameters
user_idstringRequiredMemory entity ID
memory_library_idstringOptionalMemory library ID
Response fields
request_idstringRequest ID
profile.schema_namestringProfile schema name
profile.schema_descriptionstringProfile schema description
profile.attributesarrayProfile attribute list
profile.attributes[].idstringAttribute ID
profile.attributes[].namestringAttribute name
profile.attributes[].valuestringAttribute value
Request examples
curl -X GET "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v2/apps/memory/profile_schemas/{profile_schema_id}/user_profile?user_id=user_001" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json"
from agentscope_runtime.tools.modelstudio_memory import (
GetUserProfile, GetUserProfileInput,
)
import asyncio
async def main():
get_profile = GetUserProfile()
try:
profile = await get_profile.arun(GetUserProfileInput(
schema_id="YOUR_SCHEMA_ID",
user_id="user_001"
))
for attr in profile.profile.attributes:
print(f"{attr.name}: {attr.value or 'Not extracted'}")
finally:
await get_profile.close()
asyncio.run(main())
Response example
{
"profile": {
"attributes": [
{"id": "bb28e6cd522443fc9bf7e75b1377bf9d", "name": "Age", "value": "28"},
{"id": "04eb06f5f04a437b82d07ceb088103f9", "name": "Hobbies", "value": "Playing football"},
{"id": "2eff4652a6bc47b0803635033b1e08dd", "name": "Occupation", "value": "Software engineer"}
],
"schema_description": "User information including age and interests",
"schema_name": "Basic user profile"
},
"request_id": "78cb6090-a7a5-9897-861c-082a64b43d97"
}
ImportantFor the complete profile workflow, see Using User Profiles.
Is this page helpful?