Skip to content

Commit 69e0f31

Browse files
committed
configurable baseurl, updated graph package
1 parent cbbd264 commit 69e0f31

File tree

5 files changed

+59
-61
lines changed

5 files changed

+59
-61
lines changed

app/(chat)/api/chat/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ export async function POST(request: Request) {
212212
mode: 'full',
213213
verbose: true,
214214
addMemory: 'always',
215+
baseUrl: process.env.SUPERMEMORY_BASE_URL || 'https://api.supermemory.ai',
215216
});
216217

217218
const toolsConfig = {

app/(chat)/api/documents/route.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,22 @@ export async function POST(request: Request) {
3434

3535
try {
3636
// Fetch documents from Supermemory API
37-
const baseUrl = process.env.SUPERMEMORY_BASE_URL || 'https://api.supermemory.ai';
38-
const response = await fetch(
39-
`${baseUrl}/v3/documents/documents`,
40-
{
41-
method: 'POST',
42-
headers: {
43-
'Content-Type': 'application/json',
44-
'x-api-key': process.env.SUPERMEMORY_API_KEY,
45-
},
46-
body: JSON.stringify({
47-
page,
48-
limit,
49-
sort,
50-
order,
51-
containerTags: [containerTag], // Filter by user's container tag only
52-
}),
37+
const baseUrl =
38+
process.env.SUPERMEMORY_BASE_URL || 'https://api.supermemory.ai';
39+
const response = await fetch(`${baseUrl}/v3/documents/documents`, {
40+
method: 'POST',
41+
headers: {
42+
'Content-Type': 'application/json',
43+
'x-api-key': process.env.SUPERMEMORY_API_KEY,
5344
},
54-
);
45+
body: JSON.stringify({
46+
page,
47+
limit,
48+
sort,
49+
order,
50+
containerTags: [containerTag], // Filter by user's container tag only
51+
}),
52+
});
5553

5654
if (!response.ok) {
5755
console.error(
@@ -95,6 +93,8 @@ export async function POST(request: Request) {
9593
},
9694
};
9795

96+
console.log(result);
97+
9898
return NextResponse.json(result, { status: 200 });
9999
} catch (fetchError) {
100100
console.error(

bun.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"@radix-ui/react-switch": "^1.2.6",
3737
"@radix-ui/react-tooltip": "^1.2.6",
3838
"@radix-ui/react-visually-hidden": "^1.2.2",
39-
"@supermemory/memory-graph": "^0.1.1",
40-
"@supermemory/tools": "1.3.2",
39+
"@supermemory/memory-graph": "^0.1.5",
40+
"@supermemory/tools": "^1.3.14",
4141
"@tiptap/extension-mention": "^3.6.6",
4242
"@tiptap/extension-placeholder": "^3.6.6",
4343
"@tiptap/pm": "^3.6.6",
@@ -94,7 +94,7 @@
9494
"resumable-stream": "^2.0.0",
9595
"server-only": "^0.0.1",
9696
"sonner": "^2.0.3",
97-
"supermemory": "^3.0.0-alpha.0",
97+
"supermemory": "^3.14.0",
9898
"supermemory-ai-provider": "^1.0.0",
9999
"swr": "^2.3.3",
100100
"tailwind-merge": "^3.2.0",
@@ -736,9 +736,9 @@
736736

737737
"@standard-schema/utils": ["@standard-schema/[email protected]", "", {}, "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g=="],
738738

739-
"@supermemory/memory-graph": ["@supermemory/[email protected].2", "", { "dependencies": { "@emotion/is-prop-valid": "^1.4.0", "@radix-ui/react-collapsible": "^1.1.12", "@radix-ui/react-slot": "^1.2.4", "@vanilla-extract/css": "^1.17.4", "@vanilla-extract/recipes": "^0.5.7", "@vanilla-extract/sprinkles": "^1.6.5", "lucide-react": "^0.552.0", "motion": "^12.23.24" }, "peerDependencies": { "react": ">=18.0.0", "react-dom": ">=18.0.0" } }, "sha512-W2F5sMBlVpqK2UMW8EyFNOHWsX+3veuu+s7ejYNcGOvvf3g/61cZHlN/e4LaRJlvLbkq+oPXCkW6kPZnMIb4og=="],
739+
"@supermemory/memory-graph": ["@supermemory/[email protected].5", "", { "dependencies": { "@emotion/is-prop-valid": "^1.4.0", "@radix-ui/react-collapsible": "^1.1.12", "@radix-ui/react-slot": "^1.2.4", "@vanilla-extract/css": "^1.17.4", "@vanilla-extract/recipes": "^0.5.7", "@vanilla-extract/sprinkles": "^1.6.5", "lucide-react": "^0.552.0", "motion": "^12.23.24" }, "peerDependencies": { "react": ">=18.0.0", "react-dom": ">=18.0.0" } }, "sha512-z5yQkD2cQvNYNXk+MbWvN6gg0S1tl0OgiG14MoTX3p5V+F3gJCnWlCuRrwU9zLC8X9tglz3FN3URfp5nMKLlhw=="],
740740

741-
"@supermemory/tools": ["@supermemory/[email protected].2", "", { "dependencies": { "@ai-sdk/anthropic": "^2.0.25", "@ai-sdk/openai": "^2.0.23", "@ai-sdk/provider": "^2.0.0", "ai": "^5.0.29", "openai": "^4.104.0", "supermemory": "^3.0.0-alpha.26", "zod": "^4.1.5" } }, "sha512-ndUsbpPphtgrfvVIBmqYR/VnexTOoho8fV+882r+IZlmR21dNhfsr5bIJlJpAMKsqqyqy8OG6pBPC4maav+sJA=="],
741+
"@supermemory/tools": ["@supermemory/[email protected].14", "", { "dependencies": { "@ai-sdk/anthropic": "^2.0.25", "@ai-sdk/openai": "^2.0.23", "@ai-sdk/provider": "^2.0.0", "ai": "^5.0.29", "openai": "^4.104.0", "supermemory": "^3.0.0-alpha.26", "zod": "^4.1.5" } }, "sha512-jp9r718+Qqn9AVc4NN/jy/YNEvgkpUTLL8PR+CRDaT1HT4gpf5apPaSAcK6flWtmOQBV2ACi1hmVUXB1VHthyQ=="],
742742

743743
"@swc/helpers": ["@swc/[email protected]", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g=="],
744744

@@ -1920,7 +1920,7 @@
19201920

19211921
"sucrase": ["[email protected]", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.2", "commander": "^4.0.0", "lines-and-columns": "^1.1.6", "mz": "^2.7.0", "pirates": "^4.0.1", "tinyglobby": "^0.2.11", "ts-interface-checker": "^0.1.9" }, "bin": { "sucrase": "bin/sucrase", "sucrase-node": "bin/sucrase-node" } }, "sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw=="],
19221922

1923-
"supermemory": ["supermemory@3.10.0", "", {}, "sha512-xUTn6ElIIXwizj80ELDFgXjAcBpV9LtNz7kWl+PVQfVzFHM2lOguFHaDx6GoWuWW2GpnE3ikkKPCsKpvHFgqgg=="],
1923+
"supermemory": ["supermemory@3.14.0", "", {}, "sha512-gy1C6B4wUHEIOjmvDqW6GRttEdr0TZFFZ2YVU5eTCXELPQ0zjxgwudmg2kLPI6dEIITUxw1Q6n1c+vm4ro0KSg=="],
19241924

19251925
"supermemory-ai-provider": ["[email protected]", "", { "dependencies": { "@ai-sdk/anthropic": "1.1.12", "@ai-sdk/cohere": "^1.2.10", "@ai-sdk/groq": "^1.2.9", "@ai-sdk/openai": "1.1.15", "@ai-sdk/provider": "1.0.9", "@ai-sdk/provider-utils": "2.1.10", "@total-typescript/tsconfig": "^1.0.4", "ai": "4.1.46", "supermemory": "3.0.0-alpha.0", "zod": "^3.0.0" } }, "sha512-t14mdfQHmmdPz5/syIdMDUuOBRrcXczg/IPg2SgRix1HuwfpUczruQg/XKxMz5dymWf/i2K4AcpKJbBbrvmruA=="],
19261926

components/memory-graph-dialog.tsx

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
"use client";
1+
'use client';
22

3-
import { useState, useCallback } from "react";
3+
import { useState, useCallback } from 'react';
44
import {
55
Dialog,
66
DialogContent,
77
DialogHeader,
88
DialogTitle,
9-
} from "@/components/ui/dialog";
10-
import { MemoryGraph } from "@supermemory/memory-graph";
11-
import { Button } from "@/components/ui/button";
12-
import { Network } from "lucide-react";
13-
import type { DocumentWithMemories } from "@/lib/types/supermemory";
9+
} from '@/components/ui/dialog';
10+
import { MemoryGraph } from '../../supermemory/packages/memory-graph/src';
11+
import { Button } from '@/components/ui/button';
12+
import { Network } from 'lucide-react';
13+
import type { DocumentWithMemories } from '@/lib/types/supermemory';
1414

1515
interface MemoryGraphDialogProps {
1616
open?: boolean;
@@ -37,35 +37,32 @@ export function MemoryGraphDialog({
3737
const onOpenChange = controlledOnOpenChange || setInternalOpen;
3838

3939
// Fetch documents when dialog opens
40-
const fetchDocuments = useCallback(
41-
async (page: number, limit: number = 500) => {
42-
try {
43-
const response = await fetch("/api/documents", {
44-
method: "POST",
45-
headers: {
46-
"Content-Type": "application/json",
47-
},
48-
body: JSON.stringify({
49-
page,
50-
limit,
51-
sort: "createdAt",
52-
order: "desc",
53-
}),
54-
});
55-
56-
if (!response.ok) {
57-
throw new Error("Failed to fetch documents");
58-
}
40+
const fetchDocuments = useCallback(async (page: number, limit = 500) => {
41+
try {
42+
const response = await fetch('/api/documents', {
43+
method: 'POST',
44+
headers: {
45+
'Content-Type': 'application/json',
46+
},
47+
body: JSON.stringify({
48+
page,
49+
limit,
50+
sort: 'createdAt',
51+
order: 'desc',
52+
}),
53+
});
5954

60-
const data = await response.json();
61-
return data;
62-
} catch (err) {
63-
console.error("Error fetching documents:", err);
64-
throw err;
55+
if (!response.ok) {
56+
throw new Error('Failed to fetch documents');
6557
}
66-
},
67-
[],
68-
);
58+
59+
const data = await response.json();
60+
return data;
61+
} catch (err) {
62+
console.error('Error fetching documents:', err);
63+
throw err;
64+
}
65+
}, []);
6966

7067
// Load initial documents
7168
const loadInitialDocuments = useCallback(async () => {
@@ -102,7 +99,7 @@ export function MemoryGraphDialog({
10299
setHasMore(false);
103100
}
104101
} catch (err) {
105-
console.error("Error loading more documents:", err);
102+
console.error('Error loading more documents:', err);
106103
// Don't set error state for pagination failures
107104
} finally {
108105
setIsLoadingMore(false);

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"@radix-ui/react-switch": "^1.2.6",
5151
"@radix-ui/react-tooltip": "^1.2.6",
5252
"@radix-ui/react-visually-hidden": "^1.2.2",
53-
"@supermemory/memory-graph": "^0.1.1",
54-
"@supermemory/tools": "1.3.2",
53+
"@supermemory/memory-graph": "^0.1.5",
54+
"@supermemory/tools": "^1.3.14",
5555
"@tiptap/extension-mention": "^3.6.6",
5656
"@tiptap/extension-placeholder": "^3.6.6",
5757
"@tiptap/pm": "^3.6.6",
@@ -108,7 +108,7 @@
108108
"resumable-stream": "^2.0.0",
109109
"server-only": "^0.0.1",
110110
"sonner": "^2.0.3",
111-
"supermemory": "^3.0.0-alpha.0",
111+
"supermemory": "^3.14.0",
112112
"supermemory-ai-provider": "^1.0.0",
113113
"swr": "^2.3.3",
114114
"tailwind-merge": "^3.2.0",

0 commit comments

Comments
 (0)