-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 24176b8
Showing
14 changed files
with
13,705 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2024 Vercel, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<a href="https://chat.vercel.ai/"> | ||
<img alt="Next.js 14 and App Router-ready AI chatbot." src="app/(chat)/opengraph-image.png"> | ||
<h1 align="center">Next.js AI Chatbot</h1> | ||
</a> | ||
|
||
<p align="center"> | ||
An Open-Source AI Chatbot Template Built With Next.js and the AI SDK by Vercel. | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="#features"><strong>Features</strong></a> · | ||
<a href="#model-providers"><strong>Model Providers</strong></a> · | ||
<a href="#deploy-your-own"><strong>Deploy Your Own</strong></a> · | ||
<a href="#running-locally"><strong>Running locally</strong></a> | ||
</p> | ||
<br/> | ||
|
||
## Features | ||
|
||
- [Next.js](https://nextjs.org) App Router | ||
- Advanced routing for seamless navigation and performance | ||
- React Server Components (RSCs) and Server Actions for server-side rendering and increased performance | ||
- [AI SDK](https://sdk.vercel.ai/docs) | ||
- Unified API for generating text, structured objects, and tool calls with LLMs | ||
- Hooks for building dynamic chat and generative user interfaces | ||
- Supports OpenAI (default), Anthropic, Cohere, and other model providers | ||
- [shadcn/ui](https://ui.shadcn.com) | ||
- Styling with [Tailwind CSS](https://tailwindcss.com) | ||
- Component primitives from [Radix UI](https://radix-ui.com) for accessibility and flexibility | ||
- Data Persistence | ||
- [Vercel Postgres powered by Neon](https://vercel.com/storage/postgres) for saving chat history and user data | ||
- [Vercel Blob](https://vercel.com/storage/blob) for efficient file storage | ||
- [NextAuth.js](https://github.com/nextauthjs/next-auth) | ||
- Simple and secure authentication | ||
|
||
## Model Providers | ||
|
||
This template ships with OpenAI `gpt-4o` as the default. However, with the [AI SDK](https://sdk.vercel.ai/docs), you can switch LLM providers to [OpenAI](https://openai.com), [Anthropic](https://anthropic.com), [Cohere](https://cohere.com/), and [many more](https://sdk.vercel.ai/providers/ai-sdk-providers) with just a few lines of code. | ||
|
||
## Deploy Your Own | ||
|
||
You can deploy your own version of the Next.js AI Chatbot to Vercel with one click: | ||
|
||
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fai-chatbot&env=AUTH_SECRET,OPENAI_API_KEY&envDescription=Learn%20more%20about%20how%20to%20get%20the%20API%20Keys%20for%20the%20application&envLink=https%3A%2F%2Fgithub.com%2Fvercel%2Fai-chatbot%2Fblob%2Fmain%2F.env.example&demo-title=AI%20Chatbot&demo-description=An%20Open-Source%20AI%20Chatbot%20Template%20Built%20With%20Next.js%20and%20the%20AI%20SDK%20by%20Vercel.&demo-url=https%3A%2F%2Fchat.vercel.ai&stores=[{%22type%22:%22postgres%22},{%22type%22:%22blob%22}]) | ||
|
||
## Running locally | ||
|
||
You will need to use the environment variables [defined in `.env.example`](.env.example) to run Next.js AI Chatbot. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/projects/environment-variables) for this, but a `.env` file is all that is necessary. | ||
|
||
> Note: You should not commit your `.env` file or it will expose secrets that will allow others to control access to your various OpenAI and authentication provider accounts. | ||
1. Install Vercel CLI: `npm i -g vercel` | ||
2. Link local instance with Vercel and GitHub accounts (creates `.vercel` directory): `vercel link` | ||
3. Download your environment variables: `vercel env pull` | ||
|
||
```bash | ||
pnpm install | ||
pnpm dev | ||
``` | ||
|
||
Your app template should now be running on [localhost:3000](http://localhost:3000/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", | ||
"files": { | ||
"ignoreUnknown": false, | ||
"ignore": [ | ||
"**/pnpm-lock.yaml", | ||
"lib/db/migrations", | ||
"lib/editor/react-renderer.tsx", | ||
"node_modules", | ||
".next", | ||
"public", | ||
".vercel" | ||
] | ||
}, | ||
"vcs": { | ||
"enabled": true, | ||
"clientKind": "git", | ||
"defaultBranch": "main", | ||
"useIgnoreFile": true | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"formatWithErrors": false, | ||
"indentStyle": "space", | ||
"indentWidth": 2, | ||
"lineEnding": "lf", | ||
"lineWidth": 80, | ||
"attributePosition": "auto" | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"a11y": { | ||
"useHtmlLang": "warn", // Not in recommended ruleset, turning on manually | ||
"noHeaderScope": "warn", // Not in recommended ruleset, turning on manually | ||
"useValidAriaRole": { | ||
"level": "warn", | ||
"options": { | ||
"ignoreNonDom": false, | ||
"allowInvalidRoles": ["none", "text"] | ||
} | ||
}, | ||
"useSemanticElements": "off", // Rule is buggy, revisit later | ||
"noSvgWithoutTitle": "off", // We do not intend to adhere to this rule | ||
"useMediaCaption": "off", // We would need a cultural change to turn this on | ||
"noAutofocus": "off", // We're highly intentional about when we use autofocus | ||
"noBlankTarget": "off", // Covered by Conformance | ||
"useFocusableInteractive": "off", // Disable focusable interactive element requirement | ||
"useAriaPropsForRole": "off", // Disable required ARIA attributes check | ||
"useKeyWithClickEvents": "off" // Disable keyboard event requirement with click events | ||
}, | ||
"complexity": { | ||
"noUselessStringConcat": "warn", // Not in recommended ruleset, turning on manually | ||
"noForEach": "off", // forEach is too familiar to ban | ||
"noUselessSwitchCase": "off", // Turned off due to developer preferences | ||
"noUselessThisAlias": "off" // Turned off due to developer preferences | ||
}, | ||
"correctness": { | ||
"noUnusedImports": "warn", // Not in recommended ruleset, turning on manually | ||
"useArrayLiterals": "warn", // Not in recommended ruleset, turning on manually | ||
"noNewSymbol": "warn", // Not in recommended ruleset, turning on manually | ||
"useJsxKeyInIterable": "off", // Rule is buggy, revisit later | ||
"useExhaustiveDependencies": "off", // Community feedback on this rule has been poor, we will continue with ESLint | ||
"noUnnecessaryContinue": "off" // Turned off due to developer preferences | ||
}, | ||
"security": { | ||
"noDangerouslySetInnerHtml": "off" // Covered by Conformance | ||
}, | ||
"style": { | ||
"useFragmentSyntax": "warn", // Not in recommended ruleset, turning on manually | ||
"noYodaExpression": "warn", // Not in recommended ruleset, turning on manually | ||
"useDefaultParameterLast": "warn", // Not in recommended ruleset, turning on manually | ||
"useExponentiationOperator": "off", // Obscure and arguably not easily readable | ||
"noUnusedTemplateLiteral": "off", // Stylistic opinion | ||
"noUselessElse": "off" // Stylistic opinion | ||
}, | ||
"suspicious": { | ||
"noExplicitAny": "off" // We trust Vercelians to use any only when necessary | ||
}, | ||
"nursery": { | ||
"noStaticElementInteractions": "warn", | ||
"noHeadImportInDocument": "warn", | ||
"noDocumentImportInPage": "warn", | ||
"noDuplicateElseIf": "warn", | ||
"noIrregularWhitespace": "warn", | ||
"useValidAutocomplete": "warn" | ||
} | ||
} | ||
}, | ||
"javascript": { | ||
"jsxRuntime": "reactClassic", | ||
"formatter": { | ||
"jsxQuoteStyle": "double", | ||
"quoteProperties": "asNeeded", | ||
"trailingCommas": "all", | ||
"semicolons": "always", | ||
"arrowParentheses": "always", | ||
"bracketSpacing": true, | ||
"bracketSameLine": false, | ||
"quoteStyle": "single", | ||
"attributePosition": "auto" | ||
} | ||
}, | ||
"json": { | ||
"formatter": { | ||
"enabled": true, | ||
"trailingCommas": "none" | ||
}, | ||
"parser": { | ||
"allowComments": true, | ||
"allowTrailingCommas": false | ||
} | ||
}, | ||
"css": { | ||
"formatter": { "enabled": false }, | ||
"linter": { "enabled": false } | ||
}, | ||
"organizeImports": { "enabled": false }, | ||
"overrides": [ | ||
// Playwright requires an object destructure, even if empty | ||
// https://github.com/microsoft/playwright/issues/30007 | ||
{ | ||
"include": ["playwright/**"], | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"noEmptyPattern": "off" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": true, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.ts", | ||
"css": "app/globals.css", | ||
"baseColor": "zinc", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils", | ||
"ui": "@/components/ui", | ||
"lib": "@/lib", | ||
"hooks": "@/hooks" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { config } from 'dotenv'; | ||
import { defineConfig } from 'drizzle-kit'; | ||
|
||
config({ | ||
path: '.env.local', | ||
}); | ||
|
||
export default defineConfig({ | ||
schema: './lib/db/schema.ts', | ||
out: './lib/db/migrations', | ||
dialect: 'postgresql', | ||
dbCredentials: { | ||
// biome-ignore lint: Forbidden non-null assertion. | ||
url: process.env.POSTGRES_URL!, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import NextAuth from 'next-auth'; | ||
|
||
import { authConfig } from '@/app/(auth)/auth.config'; | ||
|
||
export default NextAuth(authConfig).auth; | ||
|
||
export const config = { | ||
matcher: ['/', '/:id', '/api/:path*', '/login', '/register'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { NextConfig } from 'next'; | ||
|
||
const nextConfig: NextConfig = { | ||
experimental: { | ||
ppr: true, | ||
}, | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
hostname: 'avatar.vercel.sh', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
"name": "ai-chatbot", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev --turbo", | ||
"build": "tsx lib/db/migrate && next build", | ||
"start": "next start", | ||
"lint": "next lint && biome lint --write --unsafe", | ||
"lint:fix": "next lint --fix && biome lint --write --unsafe", | ||
"format": "biome format --write", | ||
"db:generate": "drizzle-kit generate", | ||
"db:migrate": "npx tsx lib/db/migrate.ts", | ||
"db:studio": "drizzle-kit studio", | ||
"db:push": "drizzle-kit push", | ||
"db:pull": "drizzle-kit pull", | ||
"db:check": "drizzle-kit check", | ||
"db:up": "drizzle-kit up" | ||
}, | ||
"dependencies": { | ||
"@ai-sdk/openai": "1.0.19", | ||
"@codemirror/lang-javascript": "^6.2.2", | ||
"@codemirror/lang-python": "^6.1.6", | ||
"@codemirror/state": "^6.5.0", | ||
"@codemirror/theme-one-dark": "^6.1.2", | ||
"@codemirror/view": "^6.35.3", | ||
"@radix-ui/react-alert-dialog": "^1.1.2", | ||
"@radix-ui/react-dialog": "^1.1.2", | ||
"@radix-ui/react-dropdown-menu": "^2.1.2", | ||
"@radix-ui/react-icons": "^1.3.0", | ||
"@radix-ui/react-label": "^2.1.0", | ||
"@radix-ui/react-select": "^2.1.2", | ||
"@radix-ui/react-separator": "^1.1.0", | ||
"@radix-ui/react-slot": "^1.1.0", | ||
"@radix-ui/react-tooltip": "^1.1.3", | ||
"@radix-ui/react-visually-hidden": "^1.1.0", | ||
"@vercel/analytics": "^1.3.1", | ||
"@vercel/blob": "^0.24.1", | ||
"@vercel/postgres": "^0.10.0", | ||
"ai": "4.1.1", | ||
"bcrypt-ts": "^5.0.2", | ||
"class-variance-authority": "^0.7.0", | ||
"classnames": "^2.5.1", | ||
"clsx": "^2.1.1", | ||
"codemirror": "^6.0.1", | ||
"date-fns": "^4.1.0", | ||
"diff-match-patch": "^1.0.5", | ||
"dotenv": "^16.4.5", | ||
"drizzle-orm": "^0.34.0", | ||
"fast-deep-equal": "^3.1.3", | ||
"framer-motion": "^11.3.19", | ||
"geist": "^1.3.1", | ||
"lucide-react": "^0.446.0", | ||
"nanoid": "^5.0.8", | ||
"next": "15.0.3-canary.2", | ||
"next-auth": "5.0.0-beta.25", | ||
"next-themes": "^0.3.0", | ||
"orderedmap": "^2.1.1", | ||
"postgres": "^3.4.4", | ||
"prosemirror-example-setup": "^1.2.3", | ||
"prosemirror-inputrules": "^1.4.0", | ||
"prosemirror-markdown": "^1.13.1", | ||
"prosemirror-model": "^1.23.0", | ||
"prosemirror-schema-basic": "^1.2.3", | ||
"prosemirror-schema-list": "^1.4.1", | ||
"prosemirror-state": "^1.4.3", | ||
"prosemirror-view": "^1.34.3", | ||
"react": "19.0.0-rc-45804af1-20241021", | ||
"react-dom": "19.0.0-rc-45804af1-20241021", | ||
"react-markdown": "^9.0.1", | ||
"react-resizable-panels": "^2.1.7", | ||
"remark-gfm": "^4.0.0", | ||
"server-only": "^0.0.1", | ||
"sonner": "^1.5.0", | ||
"swr": "^2.2.5", | ||
"tailwind-merge": "^2.5.2", | ||
"tailwindcss-animate": "^1.0.7", | ||
"usehooks-ts": "^3.1.0", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.9.4", | ||
"@tailwindcss/typography": "^0.5.15", | ||
"@types/d3-scale": "^4.0.8", | ||
"@types/node": "^22.8.6", | ||
"@types/pdf-parse": "^1.1.4", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"drizzle-kit": "^0.25.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-next": "14.2.5", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-import-resolver-typescript": "^3.6.3", | ||
"eslint-plugin-tailwindcss": "^3.17.5", | ||
"postcss": "^8", | ||
"tailwindcss": "^3.4.1", | ||
"tsx": "^4.19.1", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
Oops, something went wrong.