Added Typescript Docs and fixed a broken url (#2204)

This commit is contained in:
Saket Aryan
2025-02-12 23:18:23 +05:30
committed by GitHub
parent 3984b90f62
commit 2c63f4d866
3 changed files with 53 additions and 1 deletions

View File

@@ -64,7 +64,7 @@ Mem0 offers two powerful ways to leverage our technology: our [managed platform]
<Card title="Quickstart" icon="rocket" href="/quickstart">
Integrate Mem0 in a few lines of code
</Card>
<Card title="Playground" icon="play" href="playground">
<Card title="Playground" icon="play" href="https://app.mem0.ai/playground">
Mem0 in action
</Card>
<Card title="Examples" icon="lightbulb" href="/examples">

View File

@@ -3,6 +3,10 @@ title: Guide
description: 'Get started with Mem0 Platform in minutes'
---
<Note type="info">
🎉 Looking for TypeScript support? Mem0 has you covered! Check out an example [here](/platform/quickstart/#4-11-working-with-mem0-in-typescript).
</Note>
## 1. Installation
<CodeGroup>
@@ -1761,6 +1765,52 @@ curl -X DELETE "https://api.mem0.ai/v1/memories/batch/" \
```
</CodeGroup>
### 4.11 Working with Mem0 in TypeScript
Manage memories using TypeScript with Mem0. Mem0 has completet TypeScript support Below is an example demonstrating how to add and search memories.
<CodeGroup>
```typescript TypeScript
import MemoryClient, { Message, SearchOptions, MemoryOptions } from 'mem0ai';
const apiKey = 'your-api-key-here';
const client = new MemoryClient(apiKey);
// Messages
const messages: Message[] = [
{ role: "user", content: "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts." },
{ role: "assistant", content: "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions." }
];
// ADD
const memoryOptions: MemoryOptions = {
user_id: "alex",
agent_id: "travel-assistant"
}
client.add(messages, memoryOptions)
.then(result => console.log(result))
.catch(error => console.error(error));
// SEARCH
const query: string = "What do you know about me?";
const searchOptions: SearchOptions = {
user_id: "alex",
filters: {
OR: [
{ agent_id: "travel-assistant" },
{ user_id: "alex" }
]
},
threshold: 0.1,
api_version: 'v2'
}
client.search(query, searchOptions)
.then(results => console.log(results))
.catch(error => console.error(error));
```
</CodeGroup>
If you have any questions, please feel free to reach out to us using one of the following methods:
<Snippet file="get-help.mdx" />

View File

@@ -19,6 +19,8 @@ Check out our [Playground](https://mem0.dev/pd-pg) to see Mem0 in action.
Our fully managed platform provides a hassle-free way to integrate Mem0's capabilities into your AI agents and assistants. Sign up for Mem0 platform [here](https://mem0.dev/pd).
The Mem0 SDK supports both Python and JavaScript, with full [TypeScript](/platform/quickstart/#4-11-working-with-mem0-in-typescript) support as well.
Follow the steps below to get started with Mem0 Platform:
1. [Install Mem0](#1-install-mem0)