forked from TabbyML/tabby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tabby playground for q&a use case (TabbyML#493)
* init commit * support chat * add theme toggle * limit message to 2 lines * update * update formatting * update * update * update * fix formatting * update
- Loading branch information
Showing
102 changed files
with
8,116 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 @@ | ||
NEXT_PUBLIC_TABBY_SERVER_URL=http://127.0.0.1:8080 |
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,25 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/eslintrc", | ||
"root": true, | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"prettier", | ||
"plugin:tailwindcss/recommended" | ||
], | ||
"plugins": ["tailwindcss"], | ||
"rules": { | ||
"tailwindcss/no-custom-classname": "off" | ||
}, | ||
"settings": { | ||
"tailwindcss": { | ||
"callees": ["cn", "cva"], | ||
"config": "tailwind.config.js" | ||
} | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"parser": "@typescript-eslint/parser" | ||
} | ||
] | ||
} |
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,38 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
.pnp | ||
.pnp.js | ||
|
||
# testing | ||
coverage | ||
|
||
# next.js | ||
.next/ | ||
out/ | ||
build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# turbo | ||
.turbo | ||
|
||
.contentlayer | ||
.env | ||
.vercel | ||
.vscode |
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 2023 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,73 @@ | ||
<a href="https://chat.vercel.ai/"> | ||
<img alt="Next.js 13 and app template Router-ready AI chatbot." src="https://chat.vercel.ai/opengraph-image.png"> | ||
<h1 align="center">Next.js AI Chatbot</h1> | ||
</a> | ||
|
||
<p align="center"> | ||
An open-source AI chatbot app template built with Next.js, the Vercel AI SDK, OpenAI, and Vercel KV. | ||
</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> · | ||
<a href="#authors"><strong>Authors</strong></a> | ||
</p> | ||
<br/> | ||
|
||
## Features | ||
|
||
- [Next.js](https://nextjs.org) App Router | ||
- React Server Components (RSCs), Suspense, and Server Actions | ||
- [Vercel AI SDK](https://sdk.vercel.ai/docs) for streaming chat UI | ||
- Support for OpenAI (default), Anthropic, Hugging Face, or custom AI chat models and/or LangChain | ||
- Edge runtime-ready | ||
- [shadcn/ui](https://ui.shadcn.com) | ||
- Styling with [Tailwind CSS](https://tailwindcss.com) | ||
- [Radix UI](https://radix-ui.com) for headless component primitives | ||
- Icons from [Phosphor Icons](https://phosphoricons.com) | ||
- Chat History, rate limiting, and session storage with [Vercel KV](https://vercel.com/storage/kv) | ||
- [NextAuth.js](https://github.com/nextauthjs/next-auth) for authentication | ||
|
||
## Model Providers | ||
|
||
This template ships with OpenAI `gpt-3.5-turbo` as the default. However, thanks to the [Vercel AI SDK](https://sdk.vercel.ai/docs), you can switch LLM providers to [Anthropic](https://anthropic.com), [Hugging Face](https://huggingface.co), or using [LangChain](https://js.langchain.com) 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: | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?demo-title=Next.js+Chat&demo-description=A+full-featured%2C+hackable+Next.js+AI+chatbot+built+by+Vercel+Labs&demo-url=https%3A%2F%2Fchat.vercel.ai%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F4aVPvWuTmBvzM5cEdRdqeW%2F4234f9baf160f68ffb385a43c3527645%2FCleanShot_2023-06-16_at_17.09.21.png&project-name=Next.js+Chat&repository-name=nextjs-chat&repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-chatbot&from=templates&skippable-integrations=1&env=OPENAI_API_KEY%2CAUTH_GITHUB_ID%2CAUTH_GITHUB_SECRET%2CAUTH_SECRET&envDescription=How+to+get+these+env+vars&envLink=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-chatbot%2Fblob%2Fmain%2F.env.example&teamCreateStatus=hidden&stores=[{"type":"kv"}]) | ||
|
||
## Creating a KV Database Instance | ||
|
||
Follow the steps outlined in the [quick start guide](https://vercel.com/docs/storage/vercel-kv/quickstart#create-a-kv-database) provided by Vercel. This guide will assist you in creating and configuring your KV database instance on Vercel, enabling your application to interact with it. | ||
|
||
Remember to update your environment variables (`KV_URL`, `KV_REST_API_URL`, `KV_REST_API_TOKEN`, `KV_REST_API_READ_ONLY_TOKEN`) in the `.env` file with the appropriate credentials provided during the KV database setup. | ||
|
||
|
||
## 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/concepts/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/). | ||
|
||
## Authors | ||
|
||
This library is created by [Vercel](https://vercel.com) and [Next.js](https://nextjs.org) team members, with contributions from: | ||
|
||
- Jared Palmer ([@jaredpalmer](https://twitter.com/jaredpalmer)) - [Vercel](https://vercel.com) | ||
- Shu Ding ([@shuding\_](https://twitter.com/shuding_)) - [Vercel](https://vercel.com) | ||
- shadcn ([@shadcn](https://twitter.com/shadcn)) - [Contractor](https://shadcn.com) |
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,78 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer base { | ||
:root { | ||
--background: 0 0% 100%; | ||
--foreground: 240 10% 3.9%; | ||
|
||
--muted: 240 4.8% 95.9%; | ||
--muted-foreground: 240 3.8% 46.1%; | ||
|
||
--popover: 0 0% 100%; | ||
--popover-foreground: 240 10% 3.9%; | ||
|
||
--card: 0 0% 100%; | ||
--card-foreground: 240 10% 3.9%; | ||
|
||
--border: 240 5.9% 90%; | ||
--input: 240 5.9% 90%; | ||
|
||
--primary: 240 5.9% 10%; | ||
--primary-foreground: 0 0% 98%; | ||
|
||
--secondary: 240 4.8% 95.9%; | ||
--secondary-foreground: 240 5.9% 10%; | ||
|
||
--accent: 240 4.8% 95.9%; | ||
--accent-foreground: ; | ||
|
||
--destructive: 0 84.2% 60.2%; | ||
--destructive-foreground: 0 0% 98%; | ||
|
||
--ring: 240 5% 64.9%; | ||
|
||
--radius: 0.5rem; | ||
} | ||
|
||
.dark { | ||
--background: 240 10% 3.9%; | ||
--foreground: 0 0% 98%; | ||
|
||
--muted: 240 3.7% 15.9%; | ||
--muted-foreground: 240 5% 64.9%; | ||
|
||
--popover: 240 10% 3.9%; | ||
--popover-foreground: 0 0% 98%; | ||
|
||
--card: 240 10% 3.9%; | ||
--card-foreground: 0 0% 98%; | ||
|
||
--border: 240 3.7% 15.9%; | ||
--input: 240 3.7% 15.9%; | ||
|
||
--primary: 0 0% 98%; | ||
--primary-foreground: 240 5.9% 10%; | ||
|
||
--secondary: 240 3.7% 15.9%; | ||
--secondary-foreground: 0 0% 98%; | ||
|
||
--accent: 240 3.7% 15.9%; | ||
--accent-foreground: ; | ||
|
||
--destructive: 0 62.8% 30.6%; | ||
--destructive-foreground: 0 85.7% 97.3%; | ||
|
||
--ring: 240 3.7% 15.9%; | ||
} | ||
} | ||
|
||
@layer base { | ||
* { | ||
@apply border-border; | ||
} | ||
body { | ||
@apply bg-background text-foreground; | ||
} | ||
} |
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,51 @@ | ||
import { Metadata } from 'next' | ||
|
||
import { Toaster } from 'react-hot-toast' | ||
|
||
import '@/app/globals.css' | ||
import { fontMono, fontSans } from '@/lib/fonts' | ||
import { cn } from '@/lib/utils' | ||
import { TailwindIndicator } from '@/components/tailwind-indicator' | ||
import { Providers } from '@/components/providers' | ||
import { Header } from '@/components/header' | ||
|
||
export const metadata: Metadata = { | ||
title: { | ||
default: 'Tabby Playground', | ||
template: `%s - Tabby Playground` | ||
}, | ||
description: 'Tabby, an opensource, self-hosted AI coding assistant.', | ||
themeColor: [ | ||
{ media: '(prefers-color-scheme: light)', color: 'white' }, | ||
{ media: '(prefers-color-scheme: dark)', color: 'black' } | ||
], | ||
} | ||
|
||
interface RootLayoutProps { | ||
children: React.ReactNode | ||
} | ||
|
||
export default function RootLayout({ children }: RootLayoutProps) { | ||
return ( | ||
<html lang="en" suppressHydrationWarning> | ||
<head /> | ||
<body | ||
className={cn( | ||
'font-sans antialiased', | ||
fontSans.variable, | ||
fontMono.variable | ||
)} | ||
> | ||
<Toaster /> | ||
<Providers attribute="class" defaultTheme="system" enableSystem> | ||
<div className="flex flex-col min-h-screen"> | ||
{/* @ts-ignore */} | ||
<Header /> | ||
<main className="flex flex-col flex-1 bg-muted/50">{children}</main> | ||
</div> | ||
<TailwindIndicator /> | ||
</Providers> | ||
</body> | ||
</html> | ||
) | ||
} |
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,8 @@ | ||
import { nanoid } from '@/lib/utils' | ||
import { Chat } from '@/components/chat' | ||
|
||
export default function IndexPage() { | ||
const id = nanoid() | ||
|
||
return <Chat id={id} /> | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.