aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/docs/quickstart.mdx4
-rw-r--r--apps/docs/user-profiles/api.mdx45
-rw-r--r--apps/docs/user-profiles/examples.mdx51
3 files changed, 99 insertions, 1 deletions
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
+<Tip>
+**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.
+</Tip>
+
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', [])
</CodeGroup>
+## Profile with Threshold
+
+Use the optional `threshold` parameter to filter search results by relevance score:
+
+<CodeGroup>
+
+```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()
+```
+
+</CodeGroup>
+
## 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:
</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: