Adding Data to the Graph

Adding Data to the Graph

Available to Enterprise Plan customers only.

This feature is currently not available by default. Contact us for more information.

In addition to incorporating memory through chat history, Zep offers the capability to add data directly to the graph. Zep supports three distinct data types: message, text, and JSON.

The message type is ideal for adding data in the form of chat messages that are not directly associated with a Zep Session’s chat history. This encompasses any communication with a designated speaker, such as emails or previous chat logs.

The text type is designed for raw text data without a specific speaker attribution. This category includes content from internal documents, wiki articles, or company handbooks. It’s important to note that Zep does not process text directly from links or files.

The JSON type may be used to add any JSON document to Zep. This may include REST API responses or JSON-formatted business data.

The graph.add endpoint has a data size limit of 300,000 characters. Additionally, it requires a timestamp indicating when the document was created. If the creation time is unknown or irrelevant, you may use the current time.

You can add data to either an individual user’s graph by providing a user_id, or to a user group’s graph by specifying a group_id.

Here’s an example demonstrating how to add data to the graph:

1from zep_cloud.client import AsyncZep
2
3client = AsyncZep(
4 api_key=API_KEY,
5)
6
7message = await client.graph.add(
8 data=json_data,
9 user_id=user_id,
10 type="json",
11)