Share Memory Across Users Using Graphs
In this recipe, we will demonstrate how to share memory across different users by utilizing graphs. We will set up a user thread, add graph-specific data, and integrate the OpenAI client to show how to use both user and graph memory to enhance the context of a chatbot.
First, we initialize the Zep client, create a user, and create a thread:
Next, we create a new graph and add structured business data to the graph, in the form of a JSON string. This step uses the Graphs API.
Finally, we initialize the OpenAI client and define a chatbot_response
function that retrieves user and graph memory, constructs a system/developer message, and generates a contextual response. This leverages the Threads API, graph API, and the OpenAI chat completions endpoint.
This recipe demonstrated how to share memory across users by utilizing graphs with Zep. We set up user threads, added structured graph data, and integrated the OpenAI client to generate contextual responses, providing a robust approach to memory sharing across different users.