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