// Create a Zep client with your API key.usingvarclient=newZepClient(apiKey);// Create a user to associate with threads.varuser=awaitclient.SubpackageUser.AddAsync(userId:"test-user-"+Guid.NewGuid().ToString("N")[..8],firstName:"Test",lastName:"User",email:"test@example.com");// Start a new thread for the user.varthread=awaitclient.SubpackageThread.StartANewThreadAsync(threadId:"thread-"+Guid.NewGuid().ToString("N")[..8],userId:user.UserId!);// Add messages to the thread.varresponse=awaitclient.SubpackageThread.AddMessagesToAThreadAsync(threadId:thread.ThreadId!,messages:[ new ApidataThreadMessage { Content = "Hi, I'm interested in learning about temporal knowledge graphs.", Role = ApidataRoleType.User, }, new ApidataThreadMessage { Content = "Temporal knowledge graphs track how facts and relationships change over time.", Role = ApidataRoleType.Assistant, }, ],returnContext:true);// Get context for the thread based on recent messages.varcontext=awaitclient.SubpackageThread.GetUserContextAsync(threadId:thread.ThreadId!);
Graph Search
Example showing how to search a user's knowledge graph.
1 2 3 4 5 6 7 8 910111213141516171819202122
// Create a Zep client with your API key.usingvarclient=newZepClient(apiKey);// Add data to a user's knowledge graph.varuserId="test-user-"+Guid.NewGuid().ToString("N")[..8];awaitclient.SubpackageUser.AddAsync(userId:userId,firstName:"Graph",lastName:"User");awaitclient.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.varresults=awaitclient.SubpackageSearch.GraphAsync(query:"Where does Alice work?",userId:userId,limit:5);
MEAI Tools
Example showing how to use Zep as AIFunction tools with any IChatClient.
1 2 3 4 5 6 7 8 91011121314151617181920
// Create a Zep client with your API key.usingvarclient=newZepClient(apiKey);// Create AIFunction tools for use with any IChatClient.varaddMemoryTool=client.AsAddMemoryTool();varsearchMemoryTool=client.AsSearchMemoryTool();vargetContextTool=client.AsGetContextTool();varlistThreadsTool=client.AsListThreadsTool();vargetUserNodeTool=client.AsGetUserNodeTool();varaddMessagesTool=client.AsAddMessagesTool();// These tools can be passed to any IChatClient for function calling:// var chatResponse = await chatClient.GetResponseAsync(// "What do you remember about Alice?",// new() { Tools = [searchMemoryTool, getContextTool] });