From ca8eb295db1a06d50ce405b0637ca9a59aa7f4a8 Mon Sep 17 00:00:00 2001 From: Dhravya Shah Date: Thu, 8 Jan 2026 18:36:48 -0800 Subject: Add threshold parameter to profile API docs (#659) Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> --- apps/docs/quickstart.mdx | 4 +++ apps/docs/user-profiles/api.mdx | 45 ++++++++++++++++++++++++++++++- apps/docs/user-profiles/examples.mdx | 51 ++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/docs/quickstart.mdx b/apps/docs/quickstart.mdx index eeb88768..04418c4c 100644 --- a/apps/docs/quickstart.mdx +++ b/apps/docs/quickstart.mdx @@ -117,4 +117,8 @@ That's it! Supermemory automatically: - Builds and maintains user profiles (static facts + dynamic context) - Returns relevant context for personalized LLM responses + +**Optional:** Use the `threshold` parameter to filter search results by relevance score. For example: `client.profile(container_tag=USER_ID, threshold=0.7, q=query)` will only include results with a score above 0.7. + + Learn more about [User Profiles](/user-profiles) and [Search](/search/overview). diff --git a/apps/docs/user-profiles/api.mdx b/apps/docs/user-profiles/api.mdx index 73135aa6..7501e791 100644 --- a/apps/docs/user-profiles/api.mdx +++ b/apps/docs/user-profiles/api.mdx @@ -25,6 +25,7 @@ Retrieves a user's profile, optionally combined with search results. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `containerTag` | string | Yes | The container tag (usually user ID) to get profiles for | +| `threshold` | float | No | Threshold for filtering search results. Only results with a score above this threshold will be included. | | `q` | string | No | Optional search query to include search results with the profile | ## Response @@ -165,11 +166,53 @@ search_results = data.get('searchResults', {}).get('results', []) +## Profile with Threshold + +Use the optional `threshold` parameter to filter search results by relevance score: + + + +```typescript TypeScript +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: 'user_123', + threshold: 0.7, // Only include results with score > 0.7 + q: 'deployment errors yesterday' + }) +}); + +const data = await response.json(); +``` + +```python Python +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_123', + 'threshold': 0.7, # Only include results with score > 0.7 + 'q': 'deployment errors yesterday' + } +) + +data = response.json() +``` + + + ## Error Responses | Status | Description | |--------|-------------| -| `400` | Missing or invalid `containerTag` | +| `400` | Missing or invalid `containerTag` or `threshold` | | `401` | Invalid or missing API key | | `404` | Container not found | | `500` | Internal server error | diff --git a/apps/docs/user-profiles/examples.mdx b/apps/docs/user-profiles/examples.mdx index 75ae163a..496f905f 100644 --- a/apps/docs/user-profiles/examples.mdx +++ b/apps/docs/user-profiles/examples.mdx @@ -180,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: -- cgit v1.2.3