ai-sdk/docs: V5 Migration Docs (#3277)
This commit is contained in:
@@ -992,6 +992,11 @@ mode: "wide"
|
|||||||
|
|
||||||
<Tab title="Vercel AI SDK">
|
<Tab title="Vercel AI SDK">
|
||||||
|
|
||||||
|
<Update label="2025-08-05" description="v2.0.0">
|
||||||
|
**New Features:**
|
||||||
|
- **Vercel AI SDK:** Migration to AI SDK V5.
|
||||||
|
</Update>
|
||||||
|
|
||||||
<Update label="2025-06-15" description="v1.0.6">
|
<Update label="2025-06-15" description="v1.0.6">
|
||||||
**New Features:**
|
**New Features:**
|
||||||
- **Vercel AI SDK:** Added param `filter_memories`.
|
- **Vercel AI SDK:** Added param `filter_memories`.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ title: Vercel AI SDK
|
|||||||
The [**Mem0 AI SDK Provider**](https://www.npmjs.com/package/@mem0/vercel-ai-provider) is a library developed by **Mem0** to integrate with the Vercel AI SDK. This library brings enhanced AI interaction capabilities to your applications by introducing persistent memory functionality.
|
The [**Mem0 AI SDK Provider**](https://www.npmjs.com/package/@mem0/vercel-ai-provider) is a library developed by **Mem0** to integrate with the Vercel AI SDK. This library brings enhanced AI interaction capabilities to your applications by introducing persistent memory functionality.
|
||||||
|
|
||||||
<Note type="info">
|
<Note type="info">
|
||||||
🎉 Exciting news! Mem0 AI SDK now supports <strong>Graph Memory</strong>.
|
🎉 Exciting news! Mem0 AI SDK now supports <strong>Vercel AI SDK V5</strong>.
|
||||||
</Note>
|
</Note>
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
@@ -42,13 +42,11 @@ npm install @mem0/vercel-ai-provider
|
|||||||
mem0ApiKey: "m0-xxx",
|
mem0ApiKey: "m0-xxx",
|
||||||
apiKey: "provider-api-key",
|
apiKey: "provider-api-key",
|
||||||
config: {
|
config: {
|
||||||
compatibility: "strict",
|
// Options for LLM Provider
|
||||||
},
|
},
|
||||||
// Optional Mem0 Global Config
|
// Optional Mem0 Global Config
|
||||||
mem0Config: {
|
mem0Config: {
|
||||||
user_id: "mem0-user-id",
|
user_id: "mem0-user-id",
|
||||||
org_id: "mem0-org-id",
|
|
||||||
project_id: "mem0-project-id",
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@@ -60,10 +58,10 @@ npm install @mem0/vercel-ai-provider
|
|||||||
3. Add Memories to Enhance Context:
|
3. Add Memories to Enhance Context:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { LanguageModelV1Prompt } from "ai";
|
import { LanguageModelV2Prompt } from "@ai-sdk/provider";
|
||||||
import { addMemories } from "@mem0/vercel-ai-provider";
|
import { addMemories } from "@mem0/vercel-ai-provider";
|
||||||
|
|
||||||
const messages: LanguageModelV1Prompt = [
|
const messages: LanguageModelV2Prompt = [
|
||||||
{ role: "user", content: [{ type: "text", text: "I love red cars." }] },
|
{ role: "user", content: [{ type: "text", text: "I love red cars." }] },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -73,9 +71,9 @@ npm install @mem0/vercel-ai-provider
|
|||||||
### Standalone Features:
|
### Standalone Features:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
await addMemories(messages, { user_id: "borat", mem0ApiKey: "m0-xxx", org_id: "org_xx", project_id: "proj_xx" });
|
await addMemories(messages, { user_id: "borat", mem0ApiKey: "m0-xxx" });
|
||||||
await retrieveMemories(prompt, { user_id: "borat", mem0ApiKey: "m0-xxx", org_id: "org_xx", project_id: "proj_xx" });
|
await retrieveMemories(prompt, { user_id: "borat", mem0ApiKey: "m0-xxx" });
|
||||||
await getMemories(prompt, { user_id: "borat", mem0ApiKey: "m0-xxx", org_id: "org_xx", project_id: "proj_xx" });
|
await getMemories(prompt, { user_id: "borat", mem0ApiKey: "m0-xxx" });
|
||||||
```
|
```
|
||||||
> For standalone features, such as `addMemories`, `retrieveMemories`, and `getMemories`, you must either set `MEM0_API_KEY` as an environment variable or pass it directly in the function call.
|
> For standalone features, such as `addMemories`, `retrieveMemories`, and `getMemories`, you must either set `MEM0_API_KEY` as an environment variable or pass it directly in the function call.
|
||||||
|
|
||||||
@@ -144,7 +142,7 @@ npm install @mem0/vercel-ai-provider
|
|||||||
|
|
||||||
const mem0 = createMem0();
|
const mem0 = createMem0();
|
||||||
|
|
||||||
const { textStream } = await streamText({
|
const { textStream } = streamText({
|
||||||
model: mem0("gpt-4-turbo", {
|
model: mem0("gpt-4-turbo", {
|
||||||
user_id: "borat",
|
user_id: "borat",
|
||||||
}),
|
}),
|
||||||
@@ -231,9 +229,7 @@ The `getMemories` function will return an object with two keys: `results` and `r
|
|||||||
|----------|-------------------|
|
|----------|-------------------|
|
||||||
| OpenAI | openai |
|
| OpenAI | openai |
|
||||||
| Anthropic | anthropic |
|
| Anthropic | anthropic |
|
||||||
| Gemini | gemini |
|
|
||||||
| Google | google |
|
| Google | google |
|
||||||
| Mistral | mistral |
|
|
||||||
| Groq | groq |
|
| Groq | groq |
|
||||||
|
|
||||||
> **Note**: You can use `google` as provider for Gemini (Google) models. They are same and internally they use `@ai-sdk/google` package.
|
> **Note**: You can use `google` as provider for Gemini (Google) models. They are same and internally they use `@ai-sdk/google` package.
|
||||||
|
|||||||
Reference in New Issue
Block a user