Graph memory docs update (#1786)
This commit is contained in:
@@ -38,6 +38,29 @@ m = Memory.from_config(config)
|
|||||||
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})
|
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
We also support the new [OpenAI structured-outputs](https://platform.openai.com/docs/guides/structured-outputs/introduction) model.
|
||||||
|
|
||||||
|
```python
|
||||||
|
import os
|
||||||
|
from mem0 import Memory
|
||||||
|
|
||||||
|
os.environ["OPENAI_API_KEY"] = "your-api-key"
|
||||||
|
|
||||||
|
config = {
|
||||||
|
"llm": {
|
||||||
|
"provider": "openai_structured",
|
||||||
|
"config": {
|
||||||
|
"model": "gpt-4o-2024-08-06",
|
||||||
|
"temperature": 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m = Memory.from_config(config)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
All available parameters for the `openai` config are present in [Master List of All Params in Config](../config).
|
All available parameters for the `openai` config are present in [Master List of All Params in Config](../config).
|
||||||
@@ -70,7 +70,10 @@
|
|||||||
"group": "Open Source",
|
"group": "Open Source",
|
||||||
"pages": [
|
"pages": [
|
||||||
"open-source/quickstart",
|
"open-source/quickstart",
|
||||||
"open-source/graph-memory",
|
{
|
||||||
|
"group": "Graph Memory",
|
||||||
|
"pages": ["open-source/graph_memory/overview", "open-source/graph_memory/features"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"group": "LLMs",
|
"group": "LLMs",
|
||||||
"pages": [
|
"pages": [
|
||||||
|
|||||||
38
docs/open-source/graph_memory/features.mdx
Normal file
38
docs/open-source/graph_memory/features.mdx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
title: Features
|
||||||
|
description: 'Graph Memory features'
|
||||||
|
---
|
||||||
|
|
||||||
|
Graph Memory is a powerful feature that allows users to create and utilize complex relationships between pieces of information.
|
||||||
|
|
||||||
|
## Graph Memory supports the following features:
|
||||||
|
A list of features provided by Graph Memory.
|
||||||
|
|
||||||
|
### Add Customize Prompt
|
||||||
|
|
||||||
|
Users can add a customized prompt that will be used to extract specific entities from the given input text.
|
||||||
|
This allows for more targeted and relevant information extraction based on the user's needs.
|
||||||
|
Here's an example of how to add a customized prompt:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from mem0 import Memory
|
||||||
|
|
||||||
|
config = {
|
||||||
|
"graph_store": {
|
||||||
|
"provider": "neo4j",
|
||||||
|
"config": {
|
||||||
|
"url": "neo4j+s://xxx",
|
||||||
|
"username": "neo4j",
|
||||||
|
"password": "xxx"
|
||||||
|
},
|
||||||
|
"custom_prompt": "Please only extract entities containing sports related relationships and nothing else.",
|
||||||
|
},
|
||||||
|
"version": "v1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
m = Memory.from_config(config_dict=config)
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to use a managed version of Mem0, please check out [Mem0](https://app.mem0.ai). If you have any questions, please feel free to reach out to us using one of the following methods:
|
||||||
|
|
||||||
|
<Snippet file="get-help.mdx" />
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: Graph Memory
|
title: Overview
|
||||||
description: 'Enhance your memory system with graph-based knowledge representation and retrieval'
|
description: 'Enhance your memory system with graph-based knowledge representation and retrieval'
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -28,9 +28,18 @@ allowfullscreen
|
|||||||
To initialize Graph Memory you'll need to set up your configuration with graph store providers.
|
To initialize Graph Memory you'll need to set up your configuration with graph store providers.
|
||||||
Currently, we support Neo4j as a graph store provider. You can setup [Neo4j](https://neo4j.com/) locally or use the hosted [Neo4j AuraDB](https://neo4j.com/product/auradb/).
|
Currently, we support Neo4j as a graph store provider. You can setup [Neo4j](https://neo4j.com/) locally or use the hosted [Neo4j AuraDB](https://neo4j.com/product/auradb/).
|
||||||
Moreover, you also need to set the version to `v1.1` (*prior versions are not supported*).
|
Moreover, you also need to set the version to `v1.1` (*prior versions are not supported*).
|
||||||
|
|
||||||
|
User can also customize the LLM for Graph Memory from the [Supported LLM list](https://docs.mem0.ai/components/llms/overview) with three levels of configuration:
|
||||||
|
|
||||||
|
1. **Main Configuration**: If `llm` is set in the main config, it will be used for all graph operations.
|
||||||
|
2. **Graph Store Configuration**: If `llm` is set in the graph_store config, it will override the main config `llm` and be used specifically for graph operations.
|
||||||
|
3. **Default Configuration**: If no custom LLM is set, the default LLM (`gpt-4o-2024-08-06`) will be used for all graph operations.
|
||||||
|
|
||||||
Here's how you can do it:
|
Here's how you can do it:
|
||||||
|
|
||||||
```python
|
|
||||||
|
<CodeGroup>
|
||||||
|
```python Basic
|
||||||
from mem0 import Memory
|
from mem0 import Memory
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
@@ -48,6 +57,40 @@ config = {
|
|||||||
m = Memory.from_config(config_dict=config)
|
m = Memory.from_config(config_dict=config)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```python Advanced (Custom LLM)
|
||||||
|
from mem0 import Memory
|
||||||
|
|
||||||
|
config = {
|
||||||
|
"llm": {
|
||||||
|
"provider": "openai",
|
||||||
|
"config": {
|
||||||
|
"model": "gpt-4o",
|
||||||
|
"temperature": 0.2,
|
||||||
|
"max_tokens": 1500,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"graph_store": {
|
||||||
|
"provider": "neo4j",
|
||||||
|
"config": {
|
||||||
|
"url": "neo4j+s://xxx",
|
||||||
|
"username": "neo4j",
|
||||||
|
"password": "xxx"
|
||||||
|
},
|
||||||
|
"llm" : {
|
||||||
|
"provider": "openai",
|
||||||
|
"config": {
|
||||||
|
"model": "gpt-4o-mini",
|
||||||
|
"temperature": 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version": "v1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
m = Memory.from_config(config_dict=config)
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
|
||||||
## Graph Operations
|
## Graph Operations
|
||||||
The Mem0's graph supports the following operations:
|
The Mem0's graph supports the following operations:
|
||||||
|
|
||||||
Reference in New Issue
Block a user