From 9d0932971dd6f265a83d5b98bb36783456fd0907 Mon Sep 17 00:00:00 2001 From: Prateek Chhikara <46902268+prateekchhikara@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:17:23 -0700 Subject: [PATCH] Graph memory docs update (#1786) --- docs/components/llms/models/openai.mdx | 23 +++++++++ docs/mint.json | 5 +- docs/open-source/graph_memory/features.mdx | 38 +++++++++++++++ .../overview.mdx} | 47 ++++++++++++++++++- 4 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 docs/open-source/graph_memory/features.mdx rename docs/open-source/{graph-memory.mdx => graph_memory/overview.mdx} (83%) diff --git a/docs/components/llms/models/openai.mdx b/docs/components/llms/models/openai.mdx index e6586849..2002baa4 100644 --- a/docs/components/llms/models/openai.mdx +++ b/docs/components/llms/models/openai.mdx @@ -38,6 +38,29 @@ m = Memory.from_config(config) 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 All available parameters for the `openai` config are present in [Master List of All Params in Config](../config). \ No newline at end of file diff --git a/docs/mint.json b/docs/mint.json index 7b5c47a6..93ea5cd7 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -70,7 +70,10 @@ "group": "Open Source", "pages": [ "open-source/quickstart", - "open-source/graph-memory", + { + "group": "Graph Memory", + "pages": ["open-source/graph_memory/overview", "open-source/graph_memory/features"] + }, { "group": "LLMs", "pages": [ diff --git a/docs/open-source/graph_memory/features.mdx b/docs/open-source/graph_memory/features.mdx new file mode 100644 index 00000000..e865b753 --- /dev/null +++ b/docs/open-source/graph_memory/features.mdx @@ -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: + + diff --git a/docs/open-source/graph-memory.mdx b/docs/open-source/graph_memory/overview.mdx similarity index 83% rename from docs/open-source/graph-memory.mdx rename to docs/open-source/graph_memory/overview.mdx index aa060f6a..9d53f666 100644 --- a/docs/open-source/graph-memory.mdx +++ b/docs/open-source/graph_memory/overview.mdx @@ -1,5 +1,5 @@ --- -title: Graph Memory +title: Overview 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. 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*). + +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: -```python + + +```python Basic from mem0 import Memory config = { @@ -48,6 +57,40 @@ 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) +``` + + ## Graph Operations The Mem0's graph supports the following operations: