Skip to content

Zep

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official Zep OpenAPI specification using AutoSDK
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0

Usage

1
2
3
using Zep;

using var client = new ZepClient(apiKey);

Users and Threads

Basic example showing how to create users, threads, and add messages.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Create a Zep client with your API key.
using var client = new ZepClient(apiKey);

// Create a user to associate with threads.
var user = await client.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.
var thread = await client.SubpackageThread.StartANewThreadAsync(
    threadId: "thread-" + Guid.NewGuid().ToString("N")[..8],
    userId: user.UserId!);

// Add messages to the thread.
var response = await client.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.
var context = await client.SubpackageThread.GetUserContextAsync(
    threadId: thread.ThreadId!);

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

 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);

MEAI Tools

Example showing how to use Zep as AIFunction tools with any IChatClient.

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

// Create AIFunction tools for use with any IChatClient.
var addMemoryTool = client.AsAddMemoryTool();

var searchMemoryTool = client.AsSearchMemoryTool();

var getContextTool = client.AsGetContextTool();

var listThreadsTool = client.AsListThreadsTool();

var getUserNodeTool = client.AsGetUserNodeTool();

var addMessagesTool = 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] });

Support

Priority place for bugs: https://github.com/tryAGI/Zep/issues
Priority place for ideas and general questions: https://github.com/tryAGI/Zep/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.