Update apps/docs/user-profiles/examples.mdx

Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
This commit is contained in:
Dhravya Shah 2026-01-08 18:35:26 -08:00 committed by GitHub
parent aab469e4d9
commit 4c8ff9ef28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,10 +20,7 @@ async function handleChatMessage(userId: string, message: string) {
'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
containerTag: userId,
threshold: 0.7
})
body: JSON.stringify({ containerTag: userId })
});
const { profile } = await profileResponse.json();
@ -63,10 +60,7 @@ async def handle_chat_message(user_id: str, message: str):
'Authorization': f'Bearer {os.getenv("SUPERMEMORY_API_KEY")}',
'Content-Type': 'application/json'
},
json={
'containerTag': user_id,
'threshold': 0.7
}
json={'containerTag': user_id}
)
profile = response.json()['profile']
@ -115,7 +109,6 @@ async function getFullContext(userId: string, userQuery: string) {
},
body: JSON.stringify({
containerTag: userId,
threshold: 0.7,
q: userQuery // Include the user's query
})
});
@ -158,7 +151,6 @@ async def get_full_context(user_id: str, user_query: str):
},
json={
'containerTag': user_id,
'threshold': 0.7,
'q': user_query # Include the user's query
}
)
@ -188,6 +180,57 @@ Relevant Information:
</CodeGroup>
## Filtering with Threshold
Use the optional `threshold` parameter to filter search results by relevance score:
<CodeGroup>
```typescript TypeScript
async function getHighQualityContext(userId: string, userQuery: string) {
const response = await fetch('https://api.supermemory.ai/v4/profile', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
containerTag: userId,
threshold: 0.7, // Only include high-confidence results
q: userQuery
})
});
const data = await response.json();
// Only highly relevant memories are included
return data;
}
```
```python Python
async def get_high_quality_context(user_id: str, user_query: str):
response = requests.post(
'https://api.supermemory.ai/v4/profile',
headers={
'Authorization': f'Bearer {os.getenv("SUPERMEMORY_API_KEY")}',
'Content-Type': 'application/json'
},
json={
'containerTag': user_id,
'threshold': 0.7, # Only include high-confidence results
'q': user_query
}
)
data = response.json()
# Only highly relevant memories are included
return data
```
</CodeGroup>
## Separate Profile and Search
For more control, you can call profile and search endpoints separately:
@ -202,10 +245,7 @@ async function advancedContext(userId: string, query: string) {
'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
containerTag: userId,
threshold: 0.7
})
body: JSON.stringify({ containerTag: userId })
}),
fetch('https://api.supermemory.ai/v3/search', {
method: 'POST',
@ -248,10 +288,7 @@ async function withUserProfile(req, res, next) {
'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
containerTag: req.user.id,
threshold: 0.7
})
body: JSON.stringify({ containerTag: req.user.id })
});
req.userProfile = await response.json();
@ -294,10 +331,7 @@ export async function POST(req: NextRequest) {
'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
containerTag: userId,
threshold: 0.7
})
body: JSON.stringify({ containerTag: userId })
});
const { profile } = await profileRes.json();