mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-27 06:15:15 +00:00
`claude-memory.ts` moved to src/ and five files in test/ kept importing `./claude-memory`; the Mastra and AI-SDK fixtures drifted behind their installed types. Together these left `bunx tsc --noEmit` unusable for the package. - repoint the five `./claude-memory` imports at `../src/claude-memory` - add the `state` property Mastra now requires on ProcessInputArgs and ProcessOutputResultArgs (35 fixtures) - add `totalTokens` to the two LanguageModelV2Usage fixtures and drop the `rawCall` property the type no longer has - iterate with `.entries()` instead of indexing, which was tripping noUncheckedIndexedAccess once the files started resolving - pass containerTag/customId through options in test-supermemory.ts, matching the current `withSupermemory` signature - exclude test/chatapp: a standalone Next.js demo with its own package.json, lockfile and tsconfig that has no business in this package's program Repointing the import also made test/claude-memory.test.ts loadable again, and it turned out to be a live-API suite: gate it behind SUPERMEMORY_API_KEY the same way the other integration suites are, so `vitest run` no longer collects a dozen 401s.
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import { OpenAI } from "openai"
|
|
import { withSupermemory } from "./src/openai"
|
|
|
|
// Make sure to set these environment variables:
|
|
// OPENAI_API_KEY=your_openai_api_key
|
|
// SUPERMEMORY_API_KEY=your_supermemory_api_key
|
|
|
|
const openai = new OpenAI({
|
|
apiKey: process.env.OPENAI_API_KEY,
|
|
})
|
|
|
|
// Wrap OpenAI client with supermemory
|
|
const openaiWithSupermemory = withSupermemory(openai, {
|
|
containerTag: "test_user_123",
|
|
customId: "test_user_123_chat",
|
|
verbose: true, // Enable logging to see what's happening
|
|
mode: "full", // Search both profile and query memories
|
|
addMemory: "always", // Auto-save conversations as memories
|
|
})
|
|
|
|
// async function testChatCompletion() {
|
|
// console.log("\n=== Testing Chat Completion ===")
|
|
// const response = await openaiWithSupermemory.chat.completions.create({
|
|
// model: "gpt-4o-mini",
|
|
// messages: [
|
|
// { role: "user", content: "My favorite color is blue" },
|
|
// ],
|
|
// })
|
|
|
|
// console.log("Response:", response.choices[0]?.message.content)
|
|
// }
|
|
|
|
async function testResponses() {
|
|
console.log("\n=== Testing Responses API ===")
|
|
const response = await openaiWithSupermemory.chat.completions.create({
|
|
model: "gpt-4o",
|
|
messages: [{ role: "user", content: "what's my favoritge color?" }],
|
|
})
|
|
|
|
console.log(
|
|
"Response:",
|
|
JSON.stringify(response.choices[0]?.message.content, null, 2),
|
|
)
|
|
}
|
|
|
|
// Run tests
|
|
async function main() {
|
|
try {
|
|
// await testChatCompletion()
|
|
await testResponses()
|
|
} catch (error) {
|
|
console.error("Error:", error)
|
|
}
|
|
}
|
|
|
|
main()
|