Skip to content

Graph Search

Example showing how to search a user's knowledge graph.

This example assumes using Zep; is in scope and apiKey contains your Zep API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Create a Zep client with your API key.
using var client = new ZepClient(apiKey);

// Add data to a user's knowledge graph.
var userId = "test-user-" + Guid.NewGuid().ToString("N")[..8];

await client.SubpackageUser.AddAsync(
    userId: userId,
    firstName: "Graph",
    lastName: "User");

await client.SubpackageData.AddDataAsync(
    data: "Alice works at Acme Corp as a software engineer. She joined in 2023.",
    type: ModelsGraphDataType.Text,
    userId: userId,
    sourceDescription: "user_profile");

// Search the user's knowledge graph for relevant facts.
var results = await client.SubpackageSearch.GraphAsync(
    query: "Where does Alice work?",
    userId: userId,
    limit: 5);