Skip to content

Commit

Permalink
Vercel ai example (#114)
Browse files Browse the repository at this point in the history
* feat: Add vercel ai example app

* chore: Add script to seed zep to vercel ai example

* chore: Add max duration for the response

* chore: Add readme
  • Loading branch information
paul-paliychuk authored Jan 31, 2025
1 parent ec52d75 commit d64eb96
Show file tree
Hide file tree
Showing 20 changed files with 4,635 additions and 0 deletions.
41 changes: 41 additions & 0 deletions examples/vercel_ai/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
72 changes: 72 additions & 0 deletions examples/vercel_ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Vercel AI + Zep Integration Guide

This guide demonstrates how to integrate Zep with the Vercel AI SDK to build an intelligent chatbot with memory capabilities.
We'll walk through setting up a Next.js project that uses Zep to store conversation history and contextual data about users.

The guide is available [here](https://help.getzep.com/docs/ecosystem/vercel-ai).

## Setup

1. Create a `.env.local` file in your project root with your API keys:

```text
OPENAI_API_KEY=<your-openai-key>
ZEP_API_KEY=<your-zep-key>
```

2. Seed initial data:

```bash
pnpm seed
```

After running the seed script, you should see output similar to:

```text
🤖 Seeding Zep with initial data...
Adding user:
userID: Emily163733bf-8ffc-4824-9613-9d1f7a86457e
email: [email protected]
firstName: Emily
lastName: Painter
Adding session: 2a36ba9a-1fd9-4b59-8832-18f5d0eb5140
Adding chat history...
Adding transactions...
Adding account status info...
Adding support cases...
✅ Seeding complete! Please wait a few minutes for all data to be ingested into the knowledge graph.
```

Note: Save the `userID` from the output as you'll need it for the chat interface.

## Running the app

To start the development server:

```bash
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the chat interface.

## Project Structure

The main components of this project are:

- `app/page.tsx`: The chat interface component
- `app/api/chat/route.ts`: The route handler for chat functionality
- Various utility functions for working with Zep's memory and knowledge graph capabilities

## Learn More

To learn more about the technologies used in this project:

- [Vercel AI SDK Documentation](https://sdk.vercel.ai/docs)
- [Zep Documentation](https://help.getzep.com)
- [Next.js Documentation](https://nextjs.org/docs)

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new).

Check out the [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
16 changes: 16 additions & 0 deletions examples/vercel_ai/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
});

const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
];

export default eslintConfig;
7 changes: 7 additions & 0 deletions examples/vercel_ai/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
33 changes: 33 additions & 0 deletions examples/vercel_ai/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "my-ai-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint",
"seed": "pnpm dlx tsx scripts/seed_zep.ts"
},
"dependencies": {
"@ai-sdk/openai": "^1.1.5",
"@getzep/zep-cloud": "^2.3.1",
"ai": "^4.1.11",
"next": "15.1.6",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"uuid": "^11.0.5",
"zod": "^3.24.1"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.1.6",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}
Loading

0 comments on commit d64eb96

Please sign in to comment.