Customize Your Memory Context String
In this recipe, we will demonstrate how to build a custom memory context string using the graph search API. This is necessary when using group graphs, or if you want to further customize the context string. We will create and add data to a group graph, and then search the edges and nodes to create a custom context string.
First, we create a group and add some example data:
Python
TypeScript
Next, we search the graph for edges and nodes relevant to our custom query. Note that the default memory context string returned by memory.get
uses the past few messages as the query instead.
Python
TypeScript
Lastly, we use the search results to build a custom context string:
Python
TypeScript
This recipe demonstrated how to build a custom memory context string using the graph search API. We created a group and added some example data, and then searched the edges and nodes to create a custom context string.