diff --git a/app/new/page.tsx b/app/new/page.tsx new file mode 100644 index 000000000..d23589481 --- /dev/null +++ b/app/new/page.tsx @@ -0,0 +1,5 @@ +import { redirect } from 'next/navigation' + +export default async function NewPage() { + redirect('/') +} diff --git a/app/share/[id]/page.tsx b/app/share/[id]/page.tsx index 8a3361dd2..d80f0c842 100644 --- a/app/share/[id]/page.tsx +++ b/app/share/[id]/page.tsx @@ -49,7 +49,7 @@ export default async function SharePage({ params }: SharePageProps) { - + diff --git a/components/chat-list.tsx b/components/chat-list.tsx index 8cb05aa23..af744c643 100644 --- a/components/chat-list.tsx +++ b/components/chat-list.tsx @@ -1,17 +1,37 @@ import { Separator } from '@/components/ui/separator' import { UIState } from '@/lib/chat/actions' +import { Session } from '@/lib/types' +import Link from 'next/link' export interface ChatList { messages: UIState + session?: Session + isShared: boolean } -export function ChatList({ messages }: ChatList) { +export function ChatList({ messages, session, isShared }: ChatList) { if (!messages.length) { return null } return (
+ {!isShared && !session ? ( +
+

+ Please{' '} + + log in + {' '} + or{' '} + + sign up + {' '} + to save and revisit your chat history! +

+
+ ) : null} + {messages.map((message, index) => (
{message.display} diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx index 0f093a4a7..020b14233 100644 --- a/components/chat-panel.tsx +++ b/components/chat-panel.tsx @@ -27,24 +27,24 @@ export function ChatPanel({ id, title, input, setInput }: ChatPanelProps) { const exampleMessages = [ { - heading: 'Explain the concept', - subheading: 'of a serverless function', - message: `Explain the concept of a serverless function` + heading: 'What are the', + subheading: 'trending memecoins today?', + message: `What are the trending memecoins today?` }, { - heading: 'What are the benefits', - subheading: 'of using turborepo in my codebase?', - message: 'What are the benefits of using turborepo in my codebase?' + heading: 'What is the price of', + subheading: 'DOGE in the stock market?', + message: 'What is the price of DOGE in the stock market?' }, { - heading: 'List differences between', - subheading: 'pages and app router in Next.js', - message: `List differences between pages and app router in Next.js` + heading: 'I would like to buy', + subheading: '42 DOGE coins', + message: `I would like to buy 42 DOGE coins` }, { - heading: 'What is the price', - subheading: `of VRCL in the stock market?`, - message: `What is the price of VRCL in the stock market?` + heading: 'What are some', + subheading: `recent events about DOGE?`, + message: `What are some recent events about DOGE?` } ] diff --git a/components/chat.tsx b/components/chat.tsx index 27e31976c..2b7cc20c7 100644 --- a/components/chat.tsx +++ b/components/chat.tsx @@ -60,7 +60,7 @@ export function Chat({ id, className, session, missingKeys }: ChatProps) {
{messages.length ? ( <> - + ) : ( diff --git a/components/empty-screen.tsx b/components/empty-screen.tsx index 4e2eadd48..663f751d7 100644 --- a/components/empty-screen.tsx +++ b/components/empty-screen.tsx @@ -43,7 +43,7 @@ export function EmptyScreen({ setInput }: Pick) { React Server Components {' '} - to combine text with UI generated as output of the LLM. The UI state + to combine text with generative UI as output of the LLM. The UI state is synced through the SDK so the model is aware of your interactions as they happen.

diff --git a/components/footer.tsx b/components/footer.tsx index 0a8fce3c2..5ed21579a 100644 --- a/components/footer.tsx +++ b/components/footer.tsx @@ -14,8 +14,8 @@ export function FooterText({ className, ...props }: React.ComponentProps<'p'>) { > Open source AI chatbot built with{' '} Next.js and{' '} - - Vercel KV + + Vercel AI SDK .

diff --git a/components/header.tsx b/components/header.tsx index cdf57016b..3b41a04a4 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -28,7 +28,7 @@ async function UserOrLogin() { ) : ( - + diff --git a/components/prompt-form.tsx b/components/prompt-form.tsx index ac74d65c5..2271edbd5 100644 --- a/components/prompt-form.tsx +++ b/components/prompt-form.tsx @@ -72,9 +72,9 @@ export function PromptForm({
-
-
{stock.symbol}
-
${stock.price}
-
-
0 ? 'text-green-600' : 'text-red-600' - } bold text-right uppercase`} + } flex w-11 flex-row justify-center rounded-md bg-white/10 p-2`} > - {` ${((stock.delta / stock.price) * 100).toFixed(2)}%`} + {stock.delta > 0 ? '↑' : '↓'}
-
0 ? 'text-green-700' : 'text-red-700' - } text-right text-base`} - > - {stock.delta} +
+
{stock.symbol}
+
+ ${stock.price.toExponential(1)} +
+
+
+
0 ? 'text-green-600' : 'text-red-600' + } bold text-right uppercase`} + > + {` ${((stock.delta / stock.price) * 100).toExponential(1)}%`} +
+
0 ? 'text-green-700' : 'text-red-700' + } text-right text-base`} + > + {stock.delta.toExponential(1)} +
-
- - ))} + + ))} +
+
+ Note: Data and latency are simulated for illustrative purposes and + should not be considered as financial advice. +
) } diff --git a/lib/chat/actions.tsx b/lib/chat/actions.tsx index 94130d954..5134a3a81 100644 --- a/lib/chat/actions.tsx +++ b/lib/chat/actions.tsx @@ -21,7 +21,7 @@ import { import { z } from 'zod' import { EventsSkeleton } from '@/components/stocks/events-skeleton' -import { Events } from '@/components/stocks/event' +import { Events } from '@/components/stocks/events' import { StocksSkeleton } from '@/components/stocks/stocks-skeleton' import { Stocks } from '@/components/stocks/stocks' import { StockSkeleton } from '@/components/stocks/stock-skeleton' @@ -33,7 +33,7 @@ import { } from '@/lib/utils' import { saveChat } from '@/app/actions' import { SpinnerMessage, UserMessage } from '@/components/stocks/message' -import { Chat } from '@/lib/types' +import { Chat } from '../types' import { auth } from '@/auth' const openai = new OpenAI({ @@ -95,7 +95,7 @@ async function confirmPurchase(symbol: string, price: number, amount: number) { role: 'function', name: 'showStockPurchase', content: JSON.stringify({ - name: symbol, + symbol, price, defaultAmount: amount, status: 'completed' @@ -328,25 +328,16 @@ Besides that, you can also chat with users and do some calculations if needed.` }) return ( - <> - - + - + ) } }, @@ -411,12 +402,7 @@ export type Message = { export type AIState = { chatId: string - messages: { - role: 'user' | 'assistant' | 'system' | 'function' | 'data' | 'tool' - content: string - id: string - name?: string - }[] + messages: Message[] } export type UIState = { @@ -447,7 +433,7 @@ export const AI = createAI({ return } }, - unstable_onSetAIState: async ({ state }) => { + unstable_onSetAIState: async ({ state, done }) => { 'use server' const session = await auth()