Skip to content
1 change: 1 addition & 0 deletions apps/docs/ai-sdk/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const result = await generateText({

```typescript
const modelWithMemory = withSupermemory(openai("gpt-5"), "user-123", {
conversationId: "conv-1",
addMemory: "always"
})
```
Expand Down
27 changes: 27 additions & 0 deletions apps/docs/ai-sdk/user-profiles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ All of this happens transparently - you write code as if using a normal model, b

```typescript
const model = withSupermemory(openai("gpt-5"), "user-123", {
conversationId: "conv-1",
addMemory: "always"
})
```
Expand Down Expand Up @@ -117,6 +118,32 @@ const result = await generateText({
// Uses both profile (user's expertise) AND search (previous debugging sessions)
```

### Hybrid Search Mode

Use `searchMode: "hybrid"` to search both memories AND document chunks.

```typescript
const model = withSupermemory(openai("gpt-4"), "user-123", {
mode: "full",
searchMode: "hybrid", // Search memories + document chunks
searchLimit: 15 // Max results (default: 10)
})

const result = await generateText({
model,
messages: [{
role: "user",
content: "What's in my documents about quarterly goals?"
}]
})
// Searches both extracted memories AND raw document content
```

**Search Mode Options:**
- `"memories"` (default) - Search only memory entries
- `"hybrid"` - Search memories + document chunks
- `"documents"` - Search only document chunks

## Custom Prompt Templates

Customize how memories are formatted and injected into the system prompt using the `promptTemplate` option. This is useful for:
Expand Down
1 change: 1 addition & 0 deletions apps/docs/integrations/ai-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const result = await generateText({

```typescript
const modelWithMemory = withSupermemory(openai("gpt-5"), "user-123", {
conversationId: "conv-1",
addMemory: "always"
})
```
Expand Down
27 changes: 27 additions & 0 deletions packages/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,29 @@ const result = await generateText({
})
```

**Hybrid Search Mode (RAG)** - Search both memories AND document chunks:
```typescript
import { generateText } from "ai"
import { withSupermemory } from "@supermemory/tools/ai-sdk"
import { openai } from "@ai-sdk/openai"

const modelWithHybrid = withSupermemory(openai("gpt-4"), "user-123", {
mode: "full",
searchMode: "hybrid", // Search memories + document chunks
searchLimit: 15 // Max results (default: 10)
})

const result = await generateText({
model: modelWithHybrid,
messages: [{ role: "user", content: "What's in my documents about quarterly goals?" }],
})
```

Search mode options:
- `"memories"` (default) - Search only memory entries
- `"hybrid"` - Search memories + document chunks (recommended for RAG)
- `"documents"` - Search only document chunks

#### Automatic Memory Capture

The middleware can automatically save user messages as memories:
Expand Down Expand Up @@ -653,6 +676,8 @@ interface WithSupermemoryOptions {
conversationId?: string
verbose?: boolean
mode?: "profile" | "query" | "full"
searchMode?: "memories" | "hybrid" | "documents"
searchLimit?: number
addMemory?: "always" | "never"
/** Optional Supermemory API key. Use this in browser environments. */
apiKey?: string
Expand All @@ -662,6 +687,8 @@ interface WithSupermemoryOptions {
- **conversationId**: Optional conversation ID to group messages into a single document for contextual memory generation
- **verbose**: Enable detailed logging of memory search and injection process (default: false)
- **mode**: Memory search mode - "profile" (default), "query", or "full"
- **searchMode**: Search mode - "memories" (default), "hybrid", or "documents". Use "hybrid" for RAG applications
- **searchLimit**: Maximum number of search results when using hybrid/documents mode (default: 10)
- **addMemory**: Automatic memory storage mode - "always" or "never" (default: "never")

## Available Tools
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@supermemory/tools",
"type": "module",
"version": "1.4.01",
"version": "1.5.0",
"description": "Memory tools for AI SDK and OpenAI function calling with supermemory",
"scripts": {
"build": "tsdown",
Expand Down
4 changes: 4 additions & 0 deletions packages/tools/src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export type {
MemoryPromptData,
PromptTemplate,
MemoryMode,
SearchMode,
AddMemoryMode,
Logger,
ProfileStructure,
Expand Down Expand Up @@ -34,9 +35,12 @@ export {
// Memory client
export {
supermemoryProfileSearch,
supermemoryHybridSearch,
buildMemoriesText,
extractQueryText,
getLastUserMessageText,
type BuildMemoriesTextOptions,
type GenericMessage,
type SearchResultItem,
type SearchResponse,
} from "./memory-client"
Loading
Loading