Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/vercel-labs/ai-chatbot into…
Browse files Browse the repository at this point in the history
… update-deps
  • Loading branch information
leerob committed Nov 27, 2023
2 parents 7940aee + f9ce97f commit 845a93a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- [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
- Support for OpenAI (default), Anthropic, Cohere, Hugging Face, or custom AI chat models and/or LangChain
- [shadcn/ui](https://ui.shadcn.com)
- Styling with [Tailwind CSS](https://tailwindcss.com)
- [Radix UI](https://radix-ui.com) for headless component primitives
Expand All @@ -31,7 +31,7 @@

## 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.
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), [Cohere](https://cohere.com/), [Hugging Face](https://huggingface.co), or using [LangChain](https://js.langchain.com) with just a few lines of code.

## Deploy Your Own

Expand Down
9 changes: 9 additions & 0 deletions components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useState } from 'react'
import { Button } from './ui/button'
import { Input } from './ui/input'
import { toast } from 'react-hot-toast'
import { usePathname, useRouter } from 'next/navigation'

const IS_PREVIEW = process.env.VERCEL_ENV === 'preview'
export interface ChatProps extends React.ComponentProps<'div'> {
Expand All @@ -28,6 +29,8 @@ export interface ChatProps extends React.ComponentProps<'div'> {
}

export function Chat({ id, initialMessages, className }: ChatProps) {
const router = useRouter()
const path = usePathname()
const [previewToken, setPreviewToken] = useLocalStorage<string | null>(
'ai-token',
null
Expand All @@ -46,6 +49,12 @@ export function Chat({ id, initialMessages, className }: ChatProps) {
if (response.status === 401) {
toast.error(response.statusText)
}
},
onFinish() {
if (!path.includes('chat')) {
router.push(`/chat/${id}`, { shallow: true })
router.refresh()
}
}
})
return (
Expand Down
3 changes: 3 additions & 0 deletions components/ui/codeblock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ const CodeBlock: FC<Props> = memo(({ language, value }) => {
background: 'transparent',
padding: '1.5rem 1rem'
}}
lineNumberStyle={{
userSelect: "none",
}}
codeTagProps={{
style: {
fontSize: '0.9rem',
Expand Down

0 comments on commit 845a93a

Please sign in to comment.