diff --git a/docs/components/embedders/models/azure_openai.mdx b/docs/components/embedders/models/azure_openai.mdx index 9848562b..2a680958 100644 --- a/docs/components/embedders/models/azure_openai.mdx +++ b/docs/components/embedders/models/azure_openai.mdx @@ -37,7 +37,13 @@ config = { } m = Memory.from_config(config) -m.add("I'm visiting Paris", user_id="john") +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="john") ``` ### Config diff --git a/docs/components/embedders/models/gemini.mdx b/docs/components/embedders/models/gemini.mdx index 40e5cad3..077f9ca5 100644 --- a/docs/components/embedders/models/gemini.mdx +++ b/docs/components/embedders/models/gemini.mdx @@ -23,7 +23,13 @@ config = { } m = Memory.from_config(config) -m.add("I'm visiting Paris", user_id="john") +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="john") ``` ### Config diff --git a/docs/components/embedders/models/huggingface.mdx b/docs/components/embedders/models/huggingface.mdx index 4b8d8c7e..b8b00835 100644 --- a/docs/components/embedders/models/huggingface.mdx +++ b/docs/components/embedders/models/huggingface.mdx @@ -22,7 +22,13 @@ config = { } m = Memory.from_config(config) -m.add("I'm visiting Paris", user_id="john") +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="john") ``` ### Config diff --git a/docs/components/embedders/models/ollama.mdx b/docs/components/embedders/models/ollama.mdx index 263d8227..d2829a8e 100644 --- a/docs/components/embedders/models/ollama.mdx +++ b/docs/components/embedders/models/ollama.mdx @@ -18,7 +18,13 @@ config = { } m = Memory.from_config(config) -m.add("I'm visiting Paris", user_id="john") +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="john") ``` ### Config diff --git a/docs/components/embedders/models/openai.mdx b/docs/components/embedders/models/openai.mdx index 47a0e611..68be78a9 100644 --- a/docs/components/embedders/models/openai.mdx +++ b/docs/components/embedders/models/openai.mdx @@ -23,7 +23,13 @@ config = { } m = Memory.from_config(config) -m.add("I'm visiting Paris", user_id="john") +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="john") ``` ```typescript TypeScript diff --git a/docs/components/embedders/models/together.mdx b/docs/components/embedders/models/together.mdx index 160e4746..9f1695c3 100644 --- a/docs/components/embedders/models/together.mdx +++ b/docs/components/embedders/models/together.mdx @@ -25,7 +25,13 @@ config = { } m = Memory.from_config(config) -m.add("I'm visiting Paris", user_id="john") +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="john") ``` ### Config diff --git a/docs/components/embedders/models/vertexai.mdx b/docs/components/embedders/models/vertexai.mdx index f2a0a896..88cc08a3 100644 --- a/docs/components/embedders/models/vertexai.mdx +++ b/docs/components/embedders/models/vertexai.mdx @@ -25,7 +25,13 @@ config = { } m = Memory.from_config(config) -m.add("I'm visiting Paris", user_id="john") +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="john") ``` The embedding types can be one of the following: - SEMANTIC_SIMILARITY diff --git a/docs/components/llms/models/anthropic.mdx b/docs/components/llms/models/anthropic.mdx index abfdbbd5..84ed1011 100644 --- a/docs/components/llms/models/anthropic.mdx +++ b/docs/components/llms/models/anthropic.mdx @@ -26,7 +26,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ```typescript TypeScript @@ -45,7 +51,13 @@ const config = { }; const memory = new Memory(config); -await memory.add("Likes to play cricket on weekends", { userId: "alice", metadata: { category: "hobbies" } }); +const messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); ``` diff --git a/docs/components/llms/models/aws_bedrock.mdx b/docs/components/llms/models/aws_bedrock.mdx index 7578524a..bd04d99b 100644 --- a/docs/components/llms/models/aws_bedrock.mdx +++ b/docs/components/llms/models/aws_bedrock.mdx @@ -30,7 +30,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ### Config diff --git a/docs/components/llms/models/azure_openai.mdx b/docs/components/llms/models/azure_openai.mdx index ea32b673..bacb8298 100644 --- a/docs/components/llms/models/azure_openai.mdx +++ b/docs/components/llms/models/azure_openai.mdx @@ -36,7 +36,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` We also support the new [OpenAI structured-outputs](https://platform.openai.com/docs/guides/structured-outputs/introduction) model. diff --git a/docs/components/llms/models/deepseek.mdx b/docs/components/llms/models/deepseek.mdx index 77f226ab..af1783a1 100644 --- a/docs/components/llms/models/deepseek.mdx +++ b/docs/components/llms/models/deepseek.mdx @@ -26,7 +26,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` You can also configure the API base URL in the config: diff --git a/docs/components/llms/models/gemini.mdx b/docs/components/llms/models/gemini.mdx index a40c2650..4c166ea4 100644 --- a/docs/components/llms/models/gemini.mdx +++ b/docs/components/llms/models/gemini.mdx @@ -25,7 +25,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ## Config diff --git a/docs/components/llms/models/google_AI.mdx b/docs/components/llms/models/google_AI.mdx index b1c22b1e..4e08ea74 100644 --- a/docs/components/llms/models/google_AI.mdx +++ b/docs/components/llms/models/google_AI.mdx @@ -25,7 +25,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ## Config diff --git a/docs/components/llms/models/groq.mdx b/docs/components/llms/models/groq.mdx index 5f9ab866..d8f0727c 100644 --- a/docs/components/llms/models/groq.mdx +++ b/docs/components/llms/models/groq.mdx @@ -28,7 +28,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ```typescript TypeScript @@ -47,7 +53,13 @@ const config = { }; const memory = new Memory(config); -await memory.add("Likes to play cricket on weekends", { userId: "alice", metadata: { category: "hobbies" } }); +const messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); ``` diff --git a/docs/components/llms/models/litellm.mdx b/docs/components/llms/models/litellm.mdx index 00b5afb0..d66669f8 100644 --- a/docs/components/llms/models/litellm.mdx +++ b/docs/components/llms/models/litellm.mdx @@ -20,7 +20,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ## Config diff --git a/docs/components/llms/models/mistral_AI.mdx b/docs/components/llms/models/mistral_AI.mdx index 3cd7449c..fdecd625 100644 --- a/docs/components/llms/models/mistral_AI.mdx +++ b/docs/components/llms/models/mistral_AI.mdx @@ -25,7 +25,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ## Config diff --git a/docs/components/llms/models/ollama.mdx b/docs/components/llms/models/ollama.mdx index eac73685..757fd2cc 100644 --- a/docs/components/llms/models/ollama.mdx +++ b/docs/components/llms/models/ollama.mdx @@ -20,7 +20,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ## Config diff --git a/docs/components/llms/models/openai.mdx b/docs/components/llms/models/openai.mdx index c1e07504..337151eb 100644 --- a/docs/components/llms/models/openai.mdx +++ b/docs/components/llms/models/openai.mdx @@ -36,7 +36,13 @@ config = { # } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ```typescript TypeScript @@ -55,7 +61,13 @@ const config = { }; const memory = new Memory(config); -await memory.add("Likes to play cricket on weekends", { userId: "alice", metadata: { category: "hobbies" } }); +const messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); ``` diff --git a/docs/components/llms/models/together.mdx b/docs/components/llms/models/together.mdx index dd685a29..63182918 100644 --- a/docs/components/llms/models/together.mdx +++ b/docs/components/llms/models/together.mdx @@ -21,7 +21,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ## Config diff --git a/docs/components/llms/models/xAI.mdx b/docs/components/llms/models/xAI.mdx index d7a365f5..0d2ec1c9 100644 --- a/docs/components/llms/models/xAI.mdx +++ b/docs/components/llms/models/xAI.mdx @@ -27,7 +27,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ## Config diff --git a/docs/components/vectordbs/dbs/azure_ai_search.mdx b/docs/components/vectordbs/dbs/azure_ai_search.mdx index 5bb2a952..b109759c 100644 --- a/docs/components/vectordbs/dbs/azure_ai_search.mdx +++ b/docs/components/vectordbs/dbs/azure_ai_search.mdx @@ -22,7 +22,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ### Config diff --git a/docs/components/vectordbs/dbs/chroma.mdx b/docs/components/vectordbs/dbs/chroma.mdx index a5fd527e..ed798ebb 100644 --- a/docs/components/vectordbs/dbs/chroma.mdx +++ b/docs/components/vectordbs/dbs/chroma.mdx @@ -19,7 +19,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ### Config diff --git a/docs/components/vectordbs/dbs/elasticsearch.mdx b/docs/components/vectordbs/dbs/elasticsearch.mdx index fa33a929..e3f19e5d 100644 --- a/docs/components/vectordbs/dbs/elasticsearch.mdx +++ b/docs/components/vectordbs/dbs/elasticsearch.mdx @@ -29,7 +29,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ### Config diff --git a/docs/components/vectordbs/dbs/milvus.mdx b/docs/components/vectordbs/dbs/milvus.mdx index 12193f46..4e93ba0a 100644 --- a/docs/components/vectordbs/dbs/milvus.mdx +++ b/docs/components/vectordbs/dbs/milvus.mdx @@ -19,7 +19,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ### Config diff --git a/docs/components/vectordbs/dbs/opensearch.mdx b/docs/components/vectordbs/dbs/opensearch.mdx index 507d0861..e5d8f7de 100644 --- a/docs/components/vectordbs/dbs/opensearch.mdx +++ b/docs/components/vectordbs/dbs/opensearch.mdx @@ -29,7 +29,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ### Config diff --git a/docs/components/vectordbs/dbs/pgvector.mdx b/docs/components/vectordbs/dbs/pgvector.mdx index 412271df..011a3f98 100644 --- a/docs/components/vectordbs/dbs/pgvector.mdx +++ b/docs/components/vectordbs/dbs/pgvector.mdx @@ -21,7 +21,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ### Config diff --git a/docs/components/vectordbs/dbs/qdrant.mdx b/docs/components/vectordbs/dbs/qdrant.mdx index 1c6f0076..1fe21c67 100644 --- a/docs/components/vectordbs/dbs/qdrant.mdx +++ b/docs/components/vectordbs/dbs/qdrant.mdx @@ -21,7 +21,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ```typescript TypeScript @@ -40,7 +46,13 @@ const config = { }; const memory = new Memory(config); -await memory.add("Likes to play cricket on weekends", { userId: "alice", metadata: { category: "hobbies" } }); +const messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); ``` diff --git a/docs/components/vectordbs/dbs/redis.mdx b/docs/components/vectordbs/dbs/redis.mdx index 039a1aff..3e1b7cc9 100644 --- a/docs/components/vectordbs/dbs/redis.mdx +++ b/docs/components/vectordbs/dbs/redis.mdx @@ -32,7 +32,13 @@ config = { } m = Memory.from_config(config) -m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"}) +messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +m.add(messages, user_id="alice", metadata={"category": "movies"}) ``` ```typescript TypeScript @@ -52,7 +58,13 @@ const config = { }; const memory = new Memory(config); -await memory.add("Likes to play cricket on weekends", { userId: "alice", metadata: { category: "hobbies" } }); +const messages = [ + {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, + {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, + {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."}, + {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} +] +await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); ```