docs(open-source): fix OSS feature docs for v3 SDK (#5847)
This commit is contained in:
@@ -130,7 +130,7 @@ memory = Memory.from_config_file("config.yaml")
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
<Info icon="check">
|
<Info icon="check">
|
||||||
Run `memory.add(["Remember my favorite cafe in Tokyo."], user_id="alex")` and then `memory.search("favorite cafe", filters={"user_id": "alex"})`. You should see the Qdrant collection populate and the reranker mark the memory as a top hit.
|
Run `memory.add("Remember my favorite cafe in Tokyo.", user_id="alex")` and then `memory.search("favorite cafe", filters={"user_id": "alex"})`. You should see the Qdrant collection populate and the reranker mark the memory as a top hit.
|
||||||
</Info>
|
</Info>
|
||||||
|
|
||||||
## Tune component settings
|
## Tune component settings
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ icon: "bolt"
|
|||||||
</Warning>
|
</Warning>
|
||||||
|
|
||||||
<Note>
|
<Note>
|
||||||
Working in TypeScript? The Node SDK still uses synchronous calls—use `Memory` there and rely on Python’s `AsyncMemory` when you need awaited operations.
|
Working in TypeScript? The OSS `Memory` class in the Node SDK (`mem0ai/oss`) is also fully async — every method returns a `Promise` and must be `await`ed. Python’s `AsyncMemory` serves the same purpose within Python async frameworks like FastAPI. Both runtimes support awaited memory operations; choose the SDK that matches your language.
|
||||||
</Note>
|
</Note>
|
||||||
|
|
||||||
## Feature anatomy
|
## Feature anatomy
|
||||||
|
|||||||
@@ -165,8 +165,7 @@ await memory.add("Yesterday, I ordered a laptop, the order id is 12345", { userI
|
|||||||
{"memory": "Ordered a laptop", "event": "ADD"},
|
{"memory": "Ordered a laptop", "event": "ADD"},
|
||||||
{"memory": "Order ID: 12345", "event": "ADD"},
|
{"memory": "Order ID: 12345", "event": "ADD"},
|
||||||
{"memory": "Order placed yesterday", "event": "ADD"}
|
{"memory": "Order placed yesterday", "event": "ADD"}
|
||||||
],
|
]
|
||||||
"relations": []
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
@@ -188,8 +187,7 @@ await memory.add("I like going to hikes", { userId: "user123" });
|
|||||||
|
|
||||||
```json Output
|
```json Output
|
||||||
{
|
{
|
||||||
"results": [],
|
"results": []
|
||||||
"relations": []
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ Multimodal support lets Mem0 extract facts from images alongside regular text. A
|
|||||||
|
|
||||||
## Configure it
|
## Configure it
|
||||||
|
|
||||||
|
<Warning>
|
||||||
|
You must set `enable_vision: True` in your LLM config for image content to be processed. Without it, image turns are silently dropped and no vision memories are created. Example:
|
||||||
|
```python
|
||||||
|
config = {"llm": {"provider": "openai", "config": {"enable_vision": True, "vision_details": "auto"}}}
|
||||||
|
client = Memory.from_config(config)
|
||||||
|
```
|
||||||
|
</Warning>
|
||||||
|
|
||||||
### Add image messages from URLs
|
### Add image messages from URLs
|
||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
@@ -66,7 +74,7 @@ client.add(messages, user_id="alice")
|
|||||||
```
|
```
|
||||||
|
|
||||||
```ts TypeScript
|
```ts TypeScript
|
||||||
import { Memory } from "mem0ai";
|
import { Memory } from "mem0ai/oss";
|
||||||
|
|
||||||
const client = new Memory();
|
const client = new Memory();
|
||||||
|
|
||||||
@@ -123,7 +131,7 @@ client.add(messages, user_id="alice")
|
|||||||
|
|
||||||
```ts TypeScript
|
```ts TypeScript
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { Memory } from "mem0ai";
|
import { Memory } from "mem0ai/oss";
|
||||||
|
|
||||||
function encodeImage(imagePath: string) {
|
function encodeImage(imagePath: string) {
|
||||||
const buffer = fs.readFileSync(imagePath);
|
const buffer = fs.readFileSync(imagePath);
|
||||||
@@ -226,7 +234,7 @@ client.add(messages, user_id="user123")
|
|||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Python
|
```python Python
|
||||||
from mem0 import Memory
|
from mem0 import Memory
|
||||||
from mem0.exceptions import InvalidImageError, FileSizeError
|
from mem0.exceptions import ValidationError
|
||||||
|
|
||||||
client = Memory()
|
client = Memory()
|
||||||
|
|
||||||
@@ -242,16 +250,14 @@ try:
|
|||||||
client.add(messages, user_id="user123")
|
client.add(messages, user_id="user123")
|
||||||
print("Image processed successfully")
|
print("Image processed successfully")
|
||||||
|
|
||||||
except InvalidImageError:
|
except ValidationError as exc:
|
||||||
print("Invalid image format or corrupted file")
|
print(f"Image validation error: {exc}")
|
||||||
except FileSizeError:
|
|
||||||
print("Image file too large")
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print(f"Unexpected error: {exc}")
|
print(f"Unexpected error: {exc}")
|
||||||
```
|
```
|
||||||
|
|
||||||
```ts TypeScript
|
```ts TypeScript
|
||||||
import { Memory } from "mem0ai";
|
import { Memory } from "mem0ai/oss";
|
||||||
|
|
||||||
const client = new Memory();
|
const client = new Memory();
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ config = {
|
|||||||
"provider": "llm_reranker",
|
"provider": "llm_reranker",
|
||||||
"config": {
|
"config": {
|
||||||
"provider": "openai",
|
"provider": "openai",
|
||||||
"model": "gpt-4o-mini",
|
"model": "gpt-5-mini",
|
||||||
"api_key": "your-openai-api-key",
|
"api_key": "your-openai-api-key",
|
||||||
"top_k": 5
|
"top_k": 5
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ config = {
|
|||||||
"llm": {
|
"llm": {
|
||||||
"provider": "openai",
|
"provider": "openai",
|
||||||
"config": {
|
"config": {
|
||||||
"model": "gpt-4",
|
"model": "gpt-5-mini",
|
||||||
"api_key": "your-openai-api-key"
|
"api_key": "your-openai-api-key"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user