Share context across users using graphs
In this recipe, we will demonstrate how to share context 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 context 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 context, 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 context 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 context sharing across different users.