{children}
45 | ), 46 | heading4: (node, children) => ( 47 |{children}
48 | ), 49 | heading5: (node, children) => ( 50 |{children}
51 | ), 52 | heading6: (node, children) => ( 53 |{children}
54 | ), 55 | code: (node, children, parent) => { 56 | return parent.length > 1 ? ( 57 |
58 | {children}
59 |
60 | ) : (
61 |
62 | {children}
63 |
64 | );
65 | },
66 | list_item: (node, children) => {node.content}
; 88 | }, 89 | body: (node, children) => { 90 | return7 | An Open-Source AI Chatbot Template Built With Next.js and the AI SDK by Vercel. 8 |
9 | 10 |11 | Features · 12 | Model Providers · 13 | Deploy Your Own · 14 | Running locally 15 |
16 |48 | Use your email and password to sign in 49 |
50 |54 | {"Don't have an account? "} 55 | 59 | Sign up 60 | 61 | {' for free.'} 62 |
63 |52 | Create an account with your email and password 53 |
54 |58 | {'Already have an account? '} 59 | 63 | Sign in 64 | 65 | {' instead.'} 66 |
67 |
38 | {children}
39 |
40 | )}
41 |
42 | {tab === 'run' && output && (
43 | {output}
45 |
55 | {children}
56 |
57 | );
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/nextjs-ai-chatbot/components/code-editor.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import { EditorView } from '@codemirror/view';
4 | import { EditorState, Transaction } from '@codemirror/state';
5 | import { python } from '@codemirror/lang-python';
6 | import { oneDark } from '@codemirror/theme-one-dark';
7 | import { basicSetup } from 'codemirror';
8 | import React, { memo, useEffect, useRef } from 'react';
9 | import { Suggestion } from '@/lib/db/schema';
10 |
11 | type EditorProps = {
12 | content: string;
13 | saveContent: (updatedContent: string, debounce: boolean) => void;
14 | status: 'streaming' | 'idle';
15 | isCurrentVersion: boolean;
16 | currentVersionIndex: number;
17 | suggestions: Array
18 |
23 | This is an{' '}
24 |
29 | open source
30 | {' '}
31 | chatbot template built with Next.js and the AI SDK by Vercel. It uses
32 | the{' '}
33 | streamText
{' '}
34 | function in the server and the{' '}
35 | useChat
hook
36 | on the client to create a seamless chat experience.
37 |
39 | You can learn more about the AI SDK by visiting the{' '} 40 | 45 | docs 46 | 47 | . 48 |
49 |