@@ -184,6 +184,29 @@ const result = await generateText({
184184})
185185```
186186
187+ ** Hybrid Search Mode (RAG)** - Search both memories AND document chunks:
188+ ``` typescript
189+ import { generateText } from " ai"
190+ import { withSupermemory } from " @supermemory/tools/ai-sdk"
191+ import { openai } from " @ai-sdk/openai"
192+
193+ const modelWithHybrid = withSupermemory (openai (" gpt-4" ), " user-123" , {
194+ mode: " full" ,
195+ searchMode: " hybrid" , // Search memories + document chunks
196+ searchLimit: 15 // Max results (default: 10)
197+ })
198+
199+ const result = await generateText ({
200+ model: modelWithHybrid ,
201+ messages: [{ role: " user" , content: " What's in my documents about quarterly goals?" }],
202+ })
203+ ```
204+
205+ Search mode options:
206+ - ` "memories" ` (default) - Search only memory entries
207+ - ` "hybrid" ` - Search memories + document chunks (recommended for RAG)
208+ - ` "documents" ` - Search only document chunks
209+
187210#### Automatic Memory Capture
188211
189212The middleware can automatically save user messages as memories:
@@ -652,6 +675,8 @@ interface WithSupermemoryOptions {
652675 conversationId? : string
653676 verbose? : boolean
654677 mode? : " profile" | " query" | " full"
678+ searchMode? : " memories" | " hybrid" | " documents"
679+ searchLimit? : number
655680 addMemory? : " always" | " never"
656681 /** Optional Supermemory API key. Use this in browser environments. */
657682 apiKey? : string
@@ -661,6 +686,8 @@ interface WithSupermemoryOptions {
661686- ** conversationId** : Optional conversation ID to group messages into a single document for contextual memory generation
662687- ** verbose** : Enable detailed logging of memory search and injection process (default: false)
663688- ** mode** : Memory search mode - "profile" (default), "query", or "full"
689+ - ** searchMode** : Search mode - "memories" (default), "hybrid", or "documents". Use "hybrid" for RAG applications
690+ - ** searchLimit** : Maximum number of search results when using hybrid/documents mode (default: 10)
664691- ** addMemory** : Automatic memory storage mode - "always" or "never" (default: "never")
665692
666693## Available Tools
0 commit comments