From 4c8ff9ef28efbdac76e824b335710b71c70d326b Mon Sep 17 00:00:00 2001 From: Dhravya Shah Date: Thu, 8 Jan 2026 18:35:26 -0800 Subject: [PATCH] Update apps/docs/user-profiles/examples.mdx Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> --- apps/docs/user-profiles/examples.mdx | 78 ++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/apps/docs/user-profiles/examples.mdx b/apps/docs/user-profiles/examples.mdx index 452a456f..496f905f 100644 --- a/apps/docs/user-profiles/examples.mdx +++ b/apps/docs/user-profiles/examples.mdx @@ -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: +## Filtering with Threshold + +Use the optional `threshold` parameter to filter search results by relevance score: + + + +```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 +``` + + + ## 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();