Spaces:
Sleeping
Sleeping
feat: Restruct Composer and Homepage (#64)
Browse files
Files changed (18)
- app/api/vision-agent/route.ts+2-3
- app/chat/page.tsx+31-84
- app/layout.tsx+1-1
- components/Header.tsx+29
- components/chat/ChatClient.tsx+39-13
- components/chat/ChatMessage.tsx+2-7
- components/chat/Composer.tsx+100-111
- components/ui/Chip.tsx+1-1
- components/ui/Icons.tsx+23-3
- components/ui/Tooltip.tsx+1-1
- lib/db/functions.ts+3-1
- lib/hooks/useImageUpload.tsDeleted-38
- components/chat/ImageSelector.tsx → lib/hooks/useMediaUpload.tsRenamed+30-49
- lib/hooks/useScrollAnchor.tsx+4-4
- lib/hooks/useVisionAgent.ts+5-21
- package.json+1-1
- pnpm-lock.yaml+102-11
- tailwind.config.ts+48-39
16 unmodified lines171819202122232425262728 unmodified lines5657585960616216 unmodified linesmessages: MessageBase[];id: string;mediaUrl: string;enableSelfReflection: boolean;},request,) => {const { messages, mediaUrl, enableSelfReflection } = json;// const session = await auth();// if (!session?.user?.email) {28 unmodified linesformData.append('image', mediaUrl);const fetchResponse = await fetch(`https://api.dev.landing.ai/v1/agent/chat?agent_class=vision_agent&visualize_output=true&self_reflection=${enableSelfReflection}`,// `http://localhost:5001/v1/agent/chat?agent_class=vision_agent&self_reflection=${enableSelfReflection}`,{method: 'POST',16 unmodified lines1718192021222324252628 unmodified lines5556575859606116 unmodified linesmessages: MessageBase[];id: string;mediaUrl: string;},request,) => {const { messages, mediaUrl } = json;// const session = await auth();// if (!session?.user?.email) {28 unmodified linesformData.append('image', mediaUrl);const fetchResponse = await fetch(`https://api.dev.landing.ai/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,// `http://localhost:5001/v1/agent/chat?agent_class=vision_agent&self_reflection=${enableSelfReflection}`,{method: 'POST',
1234567891011121314151617181920212223242525 unmodified lines51525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127'use client';import ImageSelector from '@/components/chat/ImageSelector';import { generateInputImageMarkdown } from '@/lib/messageUtils';import { fetcher } from '@/lib/utils';import { useRouter } from 'next/navigation';import {Tooltip,TooltipContent,TooltipTrigger,} from '@/components/ui/Tooltip';import { IconDiscord, IconGitHub } from '@/components/ui/Icons';import Link from 'next/link';import { Button } from '@/components/ui/Button';import Img from '@/components/ui/Img';import { MessageRaw } from '@/lib/db/types';import { dbPostCreateChat } from '@/lib/db/functions';import { useState } from 'react';import Loading from '@/components/ui/Loading';// const EXAMPLE_URL = 'https://landing-lens-support.s3.us-east-2.amazonaws.com/vision-agent-examples/cereal-example.jpg';const EXAMPLE_URL ='https://vision-agent-dev.s3.us-east-2.amazonaws.com/examples/flower.png';const EXAMPLE_HEADER = 'Count and find';25 unmodified linesexport default function Page() {const router = useRouter();const [isUploading, setUploading] = useState<false | Number>(false);return (<div className="mx-auto max-w-2xl px-4 mt-8"><div className="rounded-lg border bg-background p-8 mb-6"><h1 className="mb-2 text-lg font-semibold">Welcome to Vision Agent</h1><p>Vision Agent is a library that helps you utilize agent frameworks foryour vision tasks. Vision Agent aims to provide an in-secondsexperience by allowing users to describe their problem in text andutilizing agent frameworks to solve the task for them.</p><div className="my-2"><Tooltip><TooltipTrigger asChild><Button variant="link" size="icon" asChild className="mr-2"><Linkhref="https://github.com/landing-ai/vision-agent"target="_blank"><IconGitHub className="size-6" /></Link></Button></TooltipTrigger><TooltipContent>Github</TooltipContent></Tooltip><Tooltip><TooltipTrigger asChild><Button variant="link" size="icon" asChild className="mr-2"><Link href="https://discord.gg/wZ2A7J69" target="_blank"><IconDiscord className="size-6" /></Link></Button></TooltipTrigger><TooltipContent>Discord</TooltipContent></Tooltip></div><ImageSelector /></div><div className="mb-4 grid grid-cols-2 gap-2 px-4 sm:px-0">{exampleMessages.map((example, index) => (<divkey={index}className={`relative cursor-pointer rounded-lg border bg-white p-4 hover:bg-zinc-50 dark:bg-zinc-950 dark:hover:bg-zinc-900 flex items-center size-full ${index > 1 && 'hidden md:block'}`}onClick={async () => {setUploading(index);const resp = await dbPostCreateChat({mediaUrl: example.url,initMessages: example.initMessages,title: example.heading,});setUploading(false);if (resp) {router.push(`/chat/${resp.id}`);}}}>{isUploading === index && (<div className="absolute top-0 left-0 size-full flex items-center justify-center bg-white/60"><Loading /></div>)}<Img src={example.url} alt="example images" className="w-1/4" /><div className="flex items-start flex-col h-full ml-3 w-3/4"><div className="text-sm font-semibold">{example.heading}</div><div className="text-sm text-zinc-600">{example.subheading}</div></div></div>))}</div></div>);}123456789101112131425 unmodified lines4041424344454647484950515253545556575859606162636465666768697071727374'use client';import { generateInputImageMarkdown } from '@/lib/messageUtils';import { useRouter } from 'next/navigation';import { MessageRaw } from '@/lib/db/types';import { useState } from 'react';import { Composer } from '@/components/chat/Composer';import { dbPostCreateChat } from '@/lib/db/functions';import { nanoid } from '@/lib/utils';const EXAMPLE_URL ='https://vision-agent-dev.s3.us-east-2.amazonaws.com/examples/flower.png';const EXAMPLE_HEADER = 'Count and find';25 unmodified linesexport default function Page() {const router = useRouter();return (<div className="mx-auto w-[1024px] max-w-full px-4 mt-[200px]"><h1 className="mb-4 text-5xl text-center">Vision Agent</h1><h4 className="mb-8 text-center">Generate code to solve your vision problem with simple prompts.</h4><ComposeronSubmit={async ({ input, mediaUrl }) => {const newId = nanoid();const resp = await dbPostCreateChat({id: newId,mediaUrl: mediaUrl,title: `conversation-${newId}`,initMessages: [{role: 'user',content:input +(mediaUrl? '\n\n' + generateInputImageMarkdown(mediaUrl): ''),},],});if (resp) {router.push(`/chat/${newId}`);}}}/></div>);}
52 unmodified lines5354555657585952 unmodified lines><div className="flex flex-col min-h-screen"><Header /><main className="flex py-8 h-[calc(100vh-64px)] bg-muted/50 overflow-hidden relative">{children}</main></div>52 unmodified lines5354555657585952 unmodified lines><div className="flex flex-col min-h-screen"><Header /><main className="flex py-8 h-[calc(100vh-64px)] bg-background overflow-hidden relative">{children}</main></div>
11 unmodified lines12131415161746 unmodified lines64656667686911 unmodified linesimport ChatSelectServer from './ChatSelectServer';import Loading from './ui/Loading';import { Skeleton } from './ui/Skeleton';export async function Header() {const session = await auth();46 unmodified lines<Button variant="link" asChild className="mr-2"><Link href="/chat">New conversation</Link></Button><IconSeparator className="size-6 text-muted-foreground/50" /><div className="flex items-center grow-0">{session?.user ? <UserMenu user={session!.user} /> : <LoginMenu />}11 unmodified lines12131415161718192021222346 unmodified lines707172737475767778798081828384858687888990919293949596979811 unmodified linesimport ChatSelectServer from './ChatSelectServer';import Loading from './ui/Loading';import { Skeleton } from './ui/Skeleton';import {Tooltip,TooltipContent,TooltipTrigger,} from '@/components/ui/Tooltip';import { IconDiscord, IconGitHub } from '@/components/ui/Icons';export async function Header() {const session = await auth();46 unmodified lines<Button variant="link" asChild className="mr-2"><Link href="/chat">New conversation</Link></Button><Tooltip><TooltipTrigger asChild><Button variant="link" size="icon" asChild className="mr-2"><Linkhref="https://github.com/landing-ai/vision-agent"target="_blank"><IconGitHub className="size-5" /></Link></Button></TooltipTrigger><TooltipContent>Github</TooltipContent></Tooltip><Tooltip><TooltipTrigger asChild><Button variant="link" size="icon" asChild className="mr-2"><Link href="https://discord.gg/wZ2A7J69" target="_blank"><IconDiscord className="size-5" /></Link></Button></TooltipTrigger><TooltipContent>Discord</TooltipContent></Tooltip><IconSeparator className="size-6 text-muted-foreground/50" /><div className="flex items-center grow-0">{session?.user ? <UserMenu user={session!.user} /> : <LoginMenu />}
4 unmodified lines56789101112131 unmodified line1516171819202122232425262728296 unmodified lines3637383940414243444546474849505152535455564 unmodified linesimport useVisionAgent from '@/lib/hooks/useVisionAgent';import { useScrollAnchor } from '@/lib/hooks/useScrollAnchor';import { Session } from 'next-auth';import { useState } from 'react';import { ChatWithMessages } from '@/lib/db/types';import { ChatMessage } from './ChatMessage';export interface ChatClientProps {chat: ChatWithMessages;1 unmodified lineconst ChatClient: React.FC<ChatClientProps> = ({ chat }) => {const { mediaUrl, id } = chat;const { messages, append, reload, stop, isLoading, input, setInput } =useVisionAgent(chat);const { messagesRef, scrollRef, visibilityRef, isAtBottom, scrollToBottom } =useScrollAnchor();return (<divclassName="h-full overflow-auto mx-auto max-w-5xl min-w-3xl border rounded-lg"ref={scrollRef}><div className="overflow-auto h-full pt-6 px-6" ref={messagesRef}>6 unmodified linesisLoading={isLoading && index === messages.length - 1}/>))}<div className="h-px w-full" ref={visibilityRef} /></div><div className="sticky bottom-3 w-full"><Composerid={id}mediaUrl={mediaUrl}isLoading={isLoading}stop={stop}append={append}reload={reload}messages={messages}input={input}setInput={setInput}/></div></div>);};4 unmodified lines5678910111213141516171 unmodified line1920212223242526272829303132333435363738396 unmodified lines464748495051525354555657585960616263646566676869707172737475767778798081824 unmodified linesimport useVisionAgent from '@/lib/hooks/useVisionAgent';import { useScrollAnchor } from '@/lib/hooks/useScrollAnchor';import { Session } from 'next-auth';import { useEffect } from 'react';import { ChatWithMessages } from '@/lib/db/types';import { ChatMessage } from './ChatMessage';import { Button } from '../ui/Button';import { cn } from '@/lib/utils';import { IconArrowDown } from '../ui/Icons';import { generateInputImageMarkdown } from '@/lib/messageUtils';export interface ChatClientProps {chat: ChatWithMessages;1 unmodified lineconst ChatClient: React.FC<ChatClientProps> = ({ chat }) => {const { mediaUrl, id } = chat;const { messages, append, isLoading, reload } = useVisionAgent(chat);const { messagesRef, scrollRef, visibilityRef, isVisible, scrollToBottom } =useScrollAnchor();// Scroll to bottom when messages are loadinguseEffect(() => {if (isLoading && messages.length) {scrollToBottom();}}, [isLoading, scrollToBottom, messages]);return (<divclassName="h-full overflow-auto mx-auto w-[1024px] max-w-full border rounded-lg relative"ref={scrollRef}><div className="overflow-auto h-full pt-6 px-6" ref={messagesRef}>6 unmodified linesisLoading={isLoading && index === messages.length - 1}/>))}<div className="h-[108px] w-full" ref={visibilityRef} /></div><div className="absolute bottom-3 w-full"><Composerid={id}mediaUrl={mediaUrl}isLoading={isLoading}onSubmit={async ({ input, mediaUrl: newMediaUrl }) => {append({id,content:input +(newMediaUrl? '\n\n' + generateInputImageMarkdown(newMediaUrl): ''),role: 'user',});}}/></div>{/* Scroll to bottom Icon */}<Buttonsize="icon"className={cn('absolute bottom-3 right-3 transition-opacity duration-300 size-6',isVisible ? 'opacity-0' : 'opacity-100',)}onClick={() => scrollToBottom()}><IconArrowDown className="size-3" /></Button></div>);};
137 unmodified lines138139140141142143144145146147148149150151152153154155156157158159160137 unmodified lines);};export function ChatMessage({message,isLoading,}: ChatMessageProps) {const { content } = useMemo(() => {return getCleanedUpMessages({content: message.content,role: message.role,});}, [message.content, message.role]);console.log('[Ming] content:', content);console.log('[Ming] raw:', message.content);const [details, setDetails] = useState<string>('');return (<divclassName={cn('group relative mb-6 flex rounded-md bg-muted px-4 py-6 w-3/5',message.role === 'user' ? 'ml-auto mr-0 w-3/5' : 'w-4/5',)}>137 unmodified lines138139140141142143144145146147148149150151152153154155137 unmodified lines);};export function ChatMessage({ message, isLoading }: ChatMessageProps) {const { content } = useMemo(() => {return getCleanedUpMessages({content: message.content,role: message.role,});}, [message.content, message.role]);const [details, setDetails] = useState<string>('');return (<divclassName={cn('group relative mb-6 flex rounded-md bg-muted p-4',message.role === 'user' ? 'ml-auto mr-0 w-3/5' : 'w-4/5',)}>
12345678910112 unmodified lines141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697982 unmodified lines101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178'use client';import * as React from 'react';import { type UseChatHelpers } from 'ai/react';import Textarea from 'react-textarea-autosize';import { Button } from '@/components/ui/Button';import { MessageBase } from '../../lib/types';import { useEnterSubmit } from '@/lib/hooks/useEnterSubmit';import Img from '../ui/Img';import {2 unmodified linesTooltipTrigger,} from '@/components/ui/Tooltip';import {IconArrowDown,IconArrowElbow,IconImage,IconRefresh,IconStop,} from '@/components/ui/Icons';import { cn } from '@/lib/utils';import { generateInputImageMarkdown } from '@/lib/messageUtils';import { Switch } from '../ui/Switch';import Chip from '../ui/Chip';export interface ComposerPropsextends Pick<UseChatHelpers,'append' | 'isLoading' | 'reload' | 'stop' | 'input' | 'setInput'> {id?: string;title?: string;messages: MessageBase[];mediaUrl?: string;}export function Composer({id,isLoading,append,input,setInput,mediaUrl,// isAtBottom,}: ComposerProps) {const { formRef, onKeyDown } = useEnterSubmit();const inputRef = React.useRef<HTMLTextAreaElement>(null);React.useEffect(() => {if (inputRef.current) {inputRef.current.focus();}}, []);const mediaName = mediaUrl?.split('/').pop();return (<div className="size-full mx-auto max-w-2xl px-6 py-3 space-y-4 bg-zinc-700 rounded-xl relative shadow-lg shadow-zinc-800/40">{mediaUrl && (<Tooltip><TooltipTrigger><Chip><div className="flex flex-row items-center"><IconImage className="size-3 mr-1" /><p>{mediaName ?? 'media(0)'}</p></div></Chip></TooltipTrigger><TooltipContent sideOffset={20}><Imgsrc={mediaUrl}className="m-1"quality={100}alt="zoomed-in-image"/></TooltipContent></Tooltip>)}<formonSubmit={async e => {e.preventDefault();if (!input?.trim()) {return;}setInput('');await append({id,content:input +(mediaUrl ? '\n\n' + generateInputImageMarkdown(mediaUrl) : ''),role: 'user',});}}ref={formRef}className="h-full">{/* <div className="border-gray-500 flex overflow-hidden size-full flex flex-row items-center"> */}<Textarea2 unmodified linesonKeyDown={onKeyDown}rows={1}value={input}disabled={isLoading}onChange={e => setInput(e.target.value)}placeholder={isLoading ? '🤖 ✨ ...' : 'Message Vision Agent'}spellCheck={false}className="w-full grow resize-none bg-transparent focus-within:outline-none text-sm"/>{/* Stop / Regenerate Icon */}{/* <div className="absolute bottom-14 right-4">{isLoading ? (<Tooltip><TooltipTrigger asChild><Buttonvariant="outline"size="icon"className="bg-background"onClick={() => stop()}><IconStop /></Button></TooltipTrigger><TooltipContent>Stop generating</TooltipContent></Tooltip>) : (messages?.length >= 2 && (<Tooltip><TooltipTrigger asChild><Buttonvariant="outline"size="icon"className="bg-background"onClick={() => reload()}><IconRefresh /></Button></TooltipTrigger><TooltipContent>Regenerate response</TooltipContent></Tooltip>))}</div> */}{/* </div> */}{/* Submit Icon */}<Tooltip><TooltipTrigger asChild><Buttontype="submit"size="icon"className="size-6 absolute bottom-3 right-3"disabled={isLoading || input === ''}><IconArrowElbow className="size-3" /></Button></TooltipTrigger><TooltipContent>Send message</TooltipContent></Tooltip></form>{/* Scroll to bottom Icon */}{/* <Tooltip><TooltipTrigger asChild><Buttonsize="icon"className={cn('absolute top-1 right-3 transition-opacity duration-300 size-6',isAtBottom ? 'opacity-0' : 'opacity-100',)}onClick={() => scrollToBottom()}><IconArrowDown className="size-3" /></Button></TooltipTrigger><TooltipContent>Scroll to bottom</TooltipContent></Tooltip> */}</div>);}123456782 unmodified lines11121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351362 unmodified lines139140141142143144145146147148149150151152153154155156157158159160161162163164165166167'use client';import { useState, useEffect, useRef } from 'react';import { Button } from '@/components/ui/Button';import { useEnterSubmit } from '@/lib/hooks/useEnterSubmit';import Img from '../ui/Img';import {2 unmodified linesTooltipTrigger,} from '@/components/ui/Tooltip';import {IconArrowElbow,IconImage,IconArrowUp,IconRefresh,IconStop,IconClose,} from '@/components/ui/Icons';import { cn } from '@/lib/utils';import { generateInputImageMarkdown } from '@/lib/messageUtils';import { Switch } from '../ui/Switch';import Chip from '../ui/Chip';import Textarea from 'react-textarea-autosize';import useMediaUpload from '@/lib/hooks/useMediaUpload';export interface ComposerProps {onSubmit: (params: { input: string; mediaUrl: string }) => Promise<void>;isLoading?: boolean;id?: string;title?: string;mediaUrl?: string;}export function Composer({ id, isLoading, onSubmit, mediaUrl }: ComposerProps) {const { formRef, onKeyDown } = useEnterSubmit();const inputRef = useRef<HTMLTextAreaElement>(null);const [localMediaUrl, setLocalMediaUrl] = useState<string | undefined>(mediaUrl,);// For local loading state such as submittingconst [localLoading, setLocalLoading] = useState<boolean>(false);const [input, setInput] = useState('');const noMediaValidation = !localMediaUrl && !!input;const { getRootProps, getInputProps, isDragActive, isUploading, openUpload } =useMediaUpload(uploadUrl => setLocalMediaUrl(uploadUrl));const finalLoading = isLoading || isUploading || localLoading;useEffect(() => {if (inputRef.current) {inputRef.current.focus();}}, []);const mediaName = localMediaUrl?.split('/').pop();return (<div{...getRootProps()}className={cn('w-full mx-auto max-w-2xl px-6 py-4 bg-zinc-700 rounded-xl relative shadow-lg shadow-zinc-700/40',isDragActive && 'bg-indigo-700/50',)}><input {...getInputProps()} /><divclassName={cn('w-1/3 h-1 rounded-full overflow-hidden bg-zinc-700 absolute left-1/2 -translate-x-1/2',finalLoading ? 'opacity-100' : 'opacity-0',)}><div className="h-full bg-primary animate-progress origin-left-right" /></div>{localMediaUrl ? (<Chip className="mb-0.5"><div className="flex flex-row items-center space-x-2"><Tooltip><TooltipTrigger><div className="flex flex-row items-center space-x-2"><IconImage className="size-3" /><p>{mediaName ?? 'unnamed_media'}</p></div></TooltipTrigger><TooltipContent sideOffset={8}><Imgsrc={localMediaUrl}className="m-1"quality={100}alt="zoomed-in-image"/></TooltipContent></Tooltip><Buttonsize="icon"variant="ghost"className="size-4"onClick={() => setLocalMediaUrl(undefined)}><IconClose className="size-3" /></Button></div></Chip>) : (<Buttonvariant="ghost"size="sm"className={cn('ml-[-10px] border-2 border-transparent',noMediaValidation && 'border-red-500/50 border-2 text-red-500',)}onClick={openUpload}><IconImage className="mr-2 size-4" />{noMediaValidation ? 'Select media (required)' : 'Select media'}</Button>)}<formonSubmit={async e => {e.preventDefault();if (!input?.trim() || !localMediaUrl) {return;}setLocalLoading(true);try {await onSubmit({ input, mediaUrl: localMediaUrl });} finally {setLocalLoading(false);setInput('');}}}ref={formRef}className="h-full mt-4">{/* <div className="border-gray-500 flex overflow-hidden size-full flex flex-row items-center"> */}<Textarea2 unmodified linesonKeyDown={onKeyDown}rows={1}value={input}disabled={finalLoading}onChange={e => setInput(e.target.value)}placeholder={finalLoading ? '🤖 Agent working ✨' : 'Message Vision Agent'}spellCheck={false}className="w-full grow resize-none bg-transparent focus-within:outline-none"/>{/* Submit Icon */}<Tooltip><TooltipTrigger asChild><Buttontype="submit"size="icon"className={cn('size-6 absolute bottom-3 right-3')}disabled={finalLoading || input === '' || noMediaValidation}><IconArrowUp className="size-3" /></Button></TooltipTrigger><TooltipContent>Message Vision Agent</TooltipContent></Tooltip></form></div>);}
16 unmodified lines1718192021222316 unmodified linesreturn (<divclassName={cn('inline-flex items-center rounded-full text-xs mr-2 bg-gray-100 text-gray-500 px-2 py-0.5',`bg-${color}-100 text-${color}-500`,className,)}16 unmodified lines1718192021222316 unmodified linesreturn (<divclassName={cn('inline-flex items-center rounded-full text-xs mr-2 bg-gray-100 text-gray-500 px-2 py-1',`bg-${color}-100 text-${color}-500`,className,)}
127 unmodified lines128129130131132133385 unmodified lines5195205215225235245255265275285295305315325338 unmodified lines542543544545546547127 unmodified lines);}function IconArrowDown({ className, ...props }: React.ComponentProps<'svg'>) {return (<svg385 unmodified lines<svgdata-testid="geist-icon"height="16"stroke-linejoin="round"viewBox="0 0 16 16"width="16"className={cn('size-4', className)}{...props}><pathfill-rule="evenodd"clip-rule="evenodd"d="M14.5 2.5H1.5V9.18933L2.96966 7.71967L3.18933 7.5H3.49999H6.63001H6.93933L6.96966 7.46967L10.4697 3.96967L11.5303 3.96967L14.5 6.93934V2.5ZM8.00066 8.55999L9.53034 10.0897L10.0607 10.62L9.00001 11.6807L8.46968 11.1503L6.31935 9H3.81065L1.53032 11.2803L1.5 11.3106V12.5C1.5 13.0523 1.94772 13.5 2.5 13.5H13.5C14.0523 13.5 14.5 13.0523 14.5 12.5V9.06066L11 5.56066L8.03032 8.53033L8.00066 8.55999ZM4.05312e-06 10.8107V12.5C4.05312e-06 13.8807 1.11929 15 2.5 15H13.5C14.8807 15 16 13.8807 16 12.5V9.56066L16.5607 9L16.0303 8.46967L16 8.43934V2.5V1H14.5H1.5H4.05312e-06V2.5V10.6893L-0.0606689 10.75L4.05312e-06 10.8107Z"fill="currentColor"></path>8 unmodified linesIconSeparator,IconArrowDown,IconArrowRight,IconUser,IconPlus,IconArrowElbow,127 unmodified lines128129130131132133134135136137138139140141142143144145146147148149150151152385 unmodified lines5385395405415425435445455465475485495505515528 unmodified lines561562563564565566567127 unmodified lines);}function IconArrowUp({ className, ...props }: React.ComponentProps<'svg'>) {return (<svgheight="16"strokeLinejoin="round"viewBox="0 0 16 16"className={cn('size-4', className)}{...props}><pathfillRule="evenodd"clipRule="evenodd"d="M8.70711 1.39644C8.31659 1.00592 7.68342 1.00592 7.2929 1.39644L2.21968 6.46966L1.68935 6.99999L2.75001 8.06065L3.28034 7.53032L7.25001 3.56065V14.25V15H8.75001V14.25V3.56065L12.7197 7.53032L13.25 8.06065L14.3107 6.99999L13.7803 6.46966L8.70711 1.39644Z"fill="currentColor"></path></svg>);}function IconArrowDown({ className, ...props }: React.ComponentProps<'svg'>) {return (<svg385 unmodified lines<svgdata-testid="geist-icon"height="16"strokeLinejoin="round"viewBox="0 0 16 16"width="16"className={cn('size-4', className)}{...props}><pathfillRule="evenodd"clipRule="evenodd"d="M14.5 2.5H1.5V9.18933L2.96966 7.71967L3.18933 7.5H3.49999H6.63001H6.93933L6.96966 7.46967L10.4697 3.96967L11.5303 3.96967L14.5 6.93934V2.5ZM8.00066 8.55999L9.53034 10.0897L10.0607 10.62L9.00001 11.6807L8.46968 11.1503L6.31935 9H3.81065L1.53032 11.2803L1.5 11.3106V12.5C1.5 13.0523 1.94772 13.5 2.5 13.5H13.5C14.0523 13.5 14.5 13.0523 14.5 12.5V9.06066L11 5.56066L8.03032 8.53033L8.00066 8.55999ZM4.05312e-06 10.8107V12.5C4.05312e-06 13.8807 1.11929 15 2.5 15H13.5C14.8807 15 16 13.8807 16 12.5V9.56066L16.5607 9L16.0303 8.46967L16 8.43934V2.5V1H14.5H1.5H4.05312e-06V2.5V10.6893L-0.0606689 10.75L4.05312e-06 10.8107Z"fill="currentColor"></path>8 unmodified linesIconSeparator,IconArrowDown,IconArrowRight,IconArrowUp,IconUser,IconPlus,IconArrowElbow,
18 unmodified lines1920212223242518 unmodified linesref={ref}sideOffset={sideOffset}className={cn('z-50 overflow-hidden rounded-md bg-muted px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',className,)}{...props}18 unmodified lines1920212223242518 unmodified linesref={ref}sideOffset={sideOffset}className={cn('z-50 overflow-hidden rounded-md bg-muted px-3 py-1.5 text-xs text-primary animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',className,)}{...props}
149 unmodified lines1501511521531541551563 unmodified lines160161162163164165149 unmodified lines}: {};return prisma.message.create({data: {content: message.content,role: message.role,3 unmodified lines...userConnect,},});}export async function dbDeleteChat(chatId: string) {149 unmodified lines1501511521531541551563 unmodified lines160161162163164165166167149 unmodified lines}: {};await prisma.message.create({data: {content: message.content,role: message.role,3 unmodified lines...userConnect,},});revalidatePath('/chat');}export async function dbDeleteChat(chatId: string) {
1234567891011121314151617181920212223242526272829303132333435363738import { DropzoneOptions, useDropzone } from 'react-dropzone';// import { toast } from 'react-hot-toast';
const useImageUpload = ( options?: Partial<DropzoneOptions>, onDrop?: (files: File[]) => void,) => { const { getRootProps, getInputProps, isDragActive } = useDropzone({ accept: { 'image/*': ['.jpeg', '.png'], 'video/mp4': ['.mp4', '.MP4'], }, multiple: false, onDrop: onDrop ? onDrop : acceptedFiles => { // if (acceptedFiles.length > 10) { // toast('You can only upload 10 images max.', { // icon: '⚠️', // }); // } acceptedFiles.forEach(file => { try { const reader = new FileReader(); reader.onloadend = () => {}; reader.readAsDataURL(file); } catch (err) { console.error(err); } }); }, ...options, });
return { getRootProps, getInputProps, isDragActive };};
export default useImageUpload;1234567891011121314151617181920212223242526272828 unmodified lines5758596061626364656633 unmodified lines100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132'use client';import React, { useCallback, useState } from 'react';import useImageUpload from '../../lib/hooks/useImageUpload';import { cn, fetcher } from '@/lib/utils';import { SignedPayload, MessageBase } from '@/lib/types';import { useRouter } from 'next/navigation';import Loading from '../ui/Loading';import toast from 'react-hot-toast';import {generateVideoThumbnails,getVideoDurationFromVideoFile,} from '@rajesh896/video-thumbnails-generator';import { ChatWithMessages } from '@/lib/db/types';import { dbPostCreateChat } from '@/lib/db/functions';export interface ImageSelectorProps {}type Example = {url: string;initMessages: MessageBase[];};const ImageSelector: React.FC<ImageSelectorProps> = () => {const router = useRouter();const [isUploading, setUploading] = useState(false);const upload = useCallback(async (file: File, chatId?: string) => {28 unmodified lines};}, []);const { getRootProps, getInputProps, isDragActive } = useImageUpload(undefined,async files => {const formData = new FormData();if (files.length !== 1) {throw new Error('Only one image can be uploaded at a time');}33 unmodified linesreturn upload(thumbnailFile, resp.id);});}await dbPostCreateChat({id: resp.id,mediaUrl: resp.publicUrl,});setUploading(false);router.push(`/chat/${resp.id}`);};},);return (<div{...getRootProps()}className={cn('dropzone border-2 border-dashed border-gray-400 w-full h-64 flex items-center justify-center rounded-lg mt-4 cursor-pointer',isDragActive && 'bg-gray-500/50 border-solid',)}><input {...getInputProps()} /><div className="text-gray-400 text-md">{isUploading ? (<Loading />) : ('Start using Vision Agent by selecting an image')}</div></div>);};export default ImageSelector;123456789101112131415161728 unmodified lines46474849505152535455565758596033 unmodified lines949596979899100101102103104105106107108109110111112113import {generateVideoThumbnails,getVideoDurationFromVideoFile,} from '@rajesh896/video-thumbnails-generator';import { useCallback, useState } from 'react';import { DropzoneOptions, useDropzone } from 'react-dropzone';import { toast } from 'react-hot-toast';import { fetcher } from '../utils';import { SignedPayload } from '../types';const useMediaUpload = (onUpload: (uploadUrl: string) => void,options?: Partial<DropzoneOptions>,) => {const [isUploading, setUploading] = useState(false);const upload = useCallback(async (file: File, chatId?: string) => {28 unmodified lines};}, []);const { getRootProps, getInputProps, isDragActive, open } = useDropzone({accept: {'image/*': ['.jpeg', '.png'],'video/mp4': ['.mp4', '.MP4'],},noClick: true,noKeyboard: true,multiple: false,onDrop: async files => {if (files.length !== 1) {throw new Error('Only one image can be uploaded at a time');}33 unmodified linesreturn upload(thumbnailFile, resp.id);});}onUpload(resp.publicUrl);setUploading(false);};},...options,});return {getRootProps,getInputProps,isDragActive,isUploading,openUpload: open,};};export default useMediaUpload;
8 unmodified lines91011121314151655 unmodified lines7273747576777810 unmodified lines8990919293948 unmodified linesconst [isVisible, setIsVisible] = useState(false);const scrollToBottom = useCallback(() => {if (messagesRef.current) {messagesRef.current.scrollIntoView({block: 'end',behavior: 'smooth',});55 unmodified lines});},{rootMargin: '0px 0px -150px 0px',},);10 unmodified linesscrollRef,visibilityRef,scrollToBottom,isAtBottom: isVisible,};};8 unmodified lines91011121314151655 unmodified lines7273747576777810 unmodified lines8990919293948 unmodified linesconst [isVisible, setIsVisible] = useState(false);const scrollToBottom = useCallback(() => {if (visibilityRef.current) {visibilityRef.current.scrollIntoView({block: 'end',behavior: 'smooth',});55 unmodified lines});},{rootMargin: '0px 0px -108px 0px',},);10 unmodified linesscrollRef,visibilityRef,scrollToBottom,isVisible,};};
52 unmodified lines5354555657585960616263646566676869707172739 unmodified lines838485868788899091929394959697989910010110210310410 unmodified lines11511611711811912012112212312452 unmodified linesconst useVisionAgent = (chat: ChatWithMessages) => {const { messages: initialMessages, id, mediaUrl } = chat;const searchParams = useSearchParams();const reflectionValue = searchParams.get('reflection');const {messages,append: appendRaw,reload,stop,isLoading,input,setInput,setMessages,error,} = useChat({api: '/api/vision-agent',onResponse(response) {if (response.status !== 200) {toast.error(response.statusText);9 unmodified linesbody: {mediaUrl,id,enableSelfReflection: reflectionValue === 'true',},});/*** If the last message is from the user, reload the chat, this would trigger to get the response from the assistant* There are 2 scenarios when this might happen* 1. Navigated from example images, init message only include preset user message* 2. Last time the assistant message failed or not saved to database.*/useEffect(() => {if (!isLoading &&messages.length &&messages[messages.length - 1].role === 'user') {reload();}}, [isLoading, messages, reload]);10 unmodified linesmessages: messages as MessageBase[],append,reload,stop,isLoading,input,setInput,};};52 unmodified lines535455565758596061626364656667689 unmodified lines787980818283848586878889909110 unmodified lines10210310410510610710852 unmodified linesconst useVisionAgent = (chat: ChatWithMessages) => {const { messages: initialMessages, id, mediaUrl } = chat;const {messages,append: appendRaw,isLoading,reload,} = useChat({api: '/api/vision-agent',// @ts-ignore https://sdk.vercel.ai/docs/troubleshooting/common-issues/use-chat-failed-to-parse-streamstreamMode: 'text',onResponse(response) {if (response.status !== 200) {toast.error(response.statusText);9 unmodified linesbody: {mediaUrl,id,},});/*** If case this is first time user navigated with init message, we need to reload the chat for the first response*/useEffect(() => {if (!isLoading && messages.length === 1 && messages[0].role === 'user') {reload();}}, [isLoading, messages, reload]);10 unmodified linesmessages: messages as MessageBase[],append,reload,isLoading,};};
27 unmodified lines2829303132333427 unmodified lines"@radix-ui/react-tooltip": "^1.0.7","@rajesh896/video-thumbnails-generator": "^2.3.9","@vercel/kv": "^1.0.1","ai": "^2.2.31","class-variance-authority": "^0.7.0","clsx": "^2.1.0","date-fns": "^3.6.0",27 unmodified lines2829303132333427 unmodified lines"@radix-ui/react-tooltip": "^1.0.7","@rajesh896/video-thumbnails-generator": "^2.3.9","@vercel/kv": "^1.0.1","ai": "^3.1.12","class-variance-authority": "^0.7.0","clsx": "^2.1.0","date-fns": "^3.6.0",
50 unmodified lines5152535455565758155 unmodified lines2142152162172182191089 unmodified lines130913101311131213131314148 unmodified lines1463146414651466146714681469147014711472147314741475147614772 unmodified lines148014811482148314841485175 unmodified lines166116621663166416651666170 unmodified lines183718381839184018411842206 unmodified lines20492050205120522053205420552056467 unmodified lines2524252525262527252825291 unmodified line253125322533253425352536820 unmodified lines335733583359336033613362474 unmodified lines3837383838393840384138421 unmodified line3844384538463847384838491604 unmodified lines545454555456545754585459183 unmodified lines56435644564556465647564856495650565156525653565456555656565756585659566056615662209 unmodified lines587258735874587558765877155 unmodified lines603360346035603660376038342 unmodified lines6381638263836384638563866387500 unmodified lines6888688968906891689268936894689568966897689868991030 unmodified lines793079317932793379347935581 unmodified lines851785188519852050 unmodified linesspecifier: ^1.0.1version: 1.0.1ai:specifier: ^2.2.31version: 2.2.37(react@18.2.0)(solid-js@1.8.16)(svelte@4.2.15)(vue@3.4.23(typescript@5.4.5))class-variance-authority:specifier: ^0.7.0version: 0.7.0155 unmodified linesresolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==}engines: {node: '>=0.10.0'}'@alloc/quick-lru@5.2.0':resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}engines: {node: '>=10'}1089 unmodified lines'@types/debug@4.1.12':resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==}'@types/estree@1.0.5':resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}148 unmodified linesresolution: {integrity: sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==}engines: {node: '>= 8.0.0'}ai@2.2.37:resolution: {integrity: sha512-JIYm5N1muGVqBqWnvkt29FmXhESoO5TcDxw74OE41SsM+uIou6NPDDs0XWb/ABcd1gmp6k5zym64KWMPM2xm0A==}engines: {node: '>=14.6'}peerDependencies:react: ^18.2.0solid-js: ^1.7.7svelte: ^3.0.0 || ^4.0.0vue: ^3.3.4peerDependenciesMeta:react:optional: truesolid-js:2 unmodified linesoptional: truevue:optional: trueajv@6.12.6:resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}175 unmodified linesresolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}engines: {node: '>=10'}character-entities-legacy@1.1.4:resolution: {integrity: sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==}170 unmodified linesdidyoumean@1.2.2:resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==}diff@5.2.0:resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==}engines: {node: '>=0.3.1'}206 unmodified linesresolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}engines: {node: '>=0.8.x'}eventsource-parser@1.0.0:resolution: {integrity: sha512-9jgfSCa3dmEme2ES3mPByGXfgZ87VbP97tng1G2nWwWx6bV2nYxm2AWCrbQjXToSe+yYlqaZNtxffR9IeQr95g==}engines: {node: '>=14.18'}extend@3.0.2:467 unmodified linesjson-schema-traverse@0.4.1:resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}json-stable-stringify-without-jsonify@1.0.1:resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==}1 unmodified lineresolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==}hasBin: truejsx-ast-utils@3.3.5:resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}engines: {node: '>=4.0'}820 unmodified linesscheduler@0.23.0:resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==}semver@6.3.1:resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}hasBin: true474 unmodified linesresolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}engines: {node: '>=10'}zwitch@2.0.4:resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}1 unmodified line'@aashutoshrathi/word-wrap@1.2.6': {}'@alloc/quick-lru@5.2.0': {}'@ampproject/remapping@2.3.0':1604 unmodified linesdependencies:'@types/ms': 0.7.34'@types/estree@1.0.5': {}'@types/hast@2.3.10':183 unmodified linesdependencies:humanize-ms: 1.2.1ai@2.2.37(react@18.2.0)(solid-js@1.8.16)(svelte@4.2.15)(vue@3.4.23(typescript@5.4.5)):dependencies:eventsource-parser: 1.0.0nanoid: 3.3.6solid-swr-store: 0.10.7(solid-js@1.8.16)(swr-store@0.10.6)sswr: 2.0.0(svelte@4.2.15)swr: 2.2.0(react@18.2.0)swr-store: 0.10.6swrv: 1.0.4(vue@3.4.23(typescript@5.4.5))optionalDependencies:react: 18.2.0solid-js: 1.8.16svelte: 4.2.15vue: 3.4.23(typescript@5.4.5)ajv@6.12.6:dependencies:209 unmodified linesansi-styles: 4.3.0supports-color: 7.2.0character-entities-legacy@1.1.4: {}character-entities@1.2.4: {}155 unmodified linesdidyoumean@1.2.2: {}diff@5.2.0: {}dir-glob@3.0.1:342 unmodified linesevents@3.3.0: {}eventsource-parser@1.0.0: {}extend@3.0.2: {}500 unmodified linesjson-schema-traverse@0.4.1: {}json-stable-stringify-without-jsonify@1.0.1: {}json5@1.0.2:dependencies:minimist: 1.2.8jsx-ast-utils@3.3.5:dependencies:array-includes: 3.1.81030 unmodified linesdependencies:loose-envify: 1.4.0semver@6.3.1: {}semver@7.6.0:581 unmodified linesyocto-queue@0.1.0: {}zwitch@2.0.4: {}50 unmodified lines5152535455565758155 unmodified lines2142152162172182192202212222232242252262272282292302312321089 unmodified lines132213231324132513261327132813291330148 unmodified lines14791480148114821483148414851486148714881489149014911492149314941495149614972 unmodified lines15001501150215031504150515061507175 unmodified lines1683168416851686168716881689169016911692170 unmodified lines186318641865186618671868186918701871206 unmodified lines20782079208020812082208320842085467 unmodified lines2553255425552556255725582559256025611 unmodified line25632564256525662567256825692570257125722573820 unmodified lines339433953396339733983399340034013402474 unmodified lines387738783879388038813882388338843885388638873888388938901 unmodified line38923893389438953896389738983899390039013902390339043905390639073908390939101604 unmodified lines55155516551755185519552055215522183 unmodified lines5706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733209 unmodified lines59435944594559465947594859495950155 unmodified lines61066107610861096110611161126113342 unmodified lines6456645764586459646064616462500 unmodified lines696369646965696669676968696969706971697269736974697569766977697869796980698169821030 unmodified lines80138014801580168017801880198020581 unmodified lines860286038604860586068607860886098610861150 unmodified linesspecifier: ^1.0.1version: 1.0.1ai:specifier: ^3.1.12version: 3.1.22(openai@4.38.1)(react@18.2.0)(solid-js@1.8.16)(svelte@4.2.15)(vue@3.4.23(typescript@5.4.5))(zod@3.23.8)class-variance-authority:specifier: ^0.7.0version: 0.7.0155 unmodified linesresolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==}engines: {node: '>=0.10.0'}'@ai-sdk/provider-utils@0.0.11':resolution: {integrity: sha512-JRDrqL2FGDmLh+a4R5qbS8UrWN9Lt7DpDIY1x6owgXjXkz3Umm1czs1X32VlL0M1dpoSxu4hGBFtXd56+kDzXA==}engines: {node: '>=18'}peerDependencies:zod: ^3.0.0peerDependenciesMeta:zod:optional: true'@ai-sdk/provider@0.0.8':resolution: {integrity: sha512-+gcMvyPUDfDXV9caN3CG5Le0M5K4CjqTdMV1ODg/AosApQiJW9ByN5imJPdI043zVdt+HS9WG+s0j4am7ca4bg==}engines: {node: '>=18'}'@alloc/quick-lru@5.2.0':resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}engines: {node: '>=10'}1089 unmodified lines'@types/debug@4.1.12':resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==}'@types/diff-match-patch@1.0.36':resolution: {integrity: sha512-xFdR6tkm0MWvBfO8xXCSsinYxHcqkQUlcHeSpMC2ukzOb6lwQAfDmW+Qt0AvlGd8HpsS28qKsB+oPeJn9I39jg==}'@types/estree@1.0.5':resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}148 unmodified linesresolution: {integrity: sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==}engines: {node: '>= 8.0.0'}ai@3.1.22:resolution: {integrity: sha512-Vgy490Q6p6pZ39VrRzL9ovr2N1YPsR+KvWNs+n73VAQoGBZtU/vwiiWrFU9LHXGhB9X+EBfQD0vixnTDS2dJWA==}engines: {node: '>=18'}peerDependencies:openai: ^4.42.0react: ^18 || ^19solid-js: ^1.7.7svelte: ^3.0.0 || ^4.0.0vue: ^3.3.4zod: ^3.0.0peerDependenciesMeta:openai:optional: truereact:optional: truesolid-js:2 unmodified linesoptional: truevue:optional: truezod:optional: trueajv@6.12.6:resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}175 unmodified linesresolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}engines: {node: '>=10'}chalk@5.3.0:resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==}engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}character-entities-legacy@1.1.4:resolution: {integrity: sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==}170 unmodified linesdidyoumean@1.2.2:resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==}diff-match-patch@1.0.5:resolution: {integrity: sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==}diff@5.2.0:resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==}engines: {node: '>=0.3.1'}206 unmodified linesresolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}engines: {node: '>=0.8.x'}eventsource-parser@1.1.2:resolution: {integrity: sha512-v0eOBUbiaFojBu2s2NPBfYUoRR9GjcDNvCXVaqEf5vVfpIAh9f8RCo4vXTP8c63QRKCFwoLpMpTdPwwhEKVgzA==}engines: {node: '>=14.18'}extend@3.0.2:467 unmodified linesjson-schema-traverse@0.4.1:resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}json-schema@0.4.0:resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==}json-stable-stringify-without-jsonify@1.0.1:resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==}1 unmodified lineresolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==}hasBin: truejsondiffpatch@0.6.0:resolution: {integrity: sha512-3QItJOXp2AP1uv7waBkao5nCvhEv+QmJAd38Ybq7wNI74Q+BBmnLn4EDKz6yI9xGAIQoUF87qHt+kc1IVxB4zQ==}engines: {node: ^18.0.0 || >=20.0.0}hasBin: truejsx-ast-utils@3.3.5:resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}engines: {node: '>=4.0'}820 unmodified linesscheduler@0.23.0:resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==}secure-json-parse@2.7.0:resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==}semver@6.3.1:resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}hasBin: true474 unmodified linesresolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}engines: {node: '>=10'}zod-to-json-schema@3.22.5:resolution: {integrity: sha512-+akaPo6a0zpVCCseDed504KBJUQpEW5QZw7RMneNmKw+fGaML1Z9tUNLnHHAC8x6dzVRO1eB2oEMyZRnuBZg7Q==}peerDependencies:zod: ^3.22.4zod@3.23.8:resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==}zwitch@2.0.4:resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}1 unmodified line'@aashutoshrathi/word-wrap@1.2.6': {}'@ai-sdk/provider-utils@0.0.11(zod@3.23.8)':dependencies:'@ai-sdk/provider': 0.0.8eventsource-parser: 1.1.2nanoid: 3.3.6secure-json-parse: 2.7.0optionalDependencies:zod: 3.23.8'@ai-sdk/provider@0.0.8':dependencies:json-schema: 0.4.0'@alloc/quick-lru@5.2.0': {}'@ampproject/remapping@2.3.0':1604 unmodified linesdependencies:'@types/ms': 0.7.34'@types/diff-match-patch@1.0.36': {}'@types/estree@1.0.5': {}'@types/hast@2.3.10':183 unmodified linesdependencies:humanize-ms: 1.2.1ai@3.1.22(openai@4.38.1)(react@18.2.0)(solid-js@1.8.16)(svelte@4.2.15)(vue@3.4.23(typescript@5.4.5))(zod@3.23.8):dependencies:'@ai-sdk/provider': 0.0.8'@ai-sdk/provider-utils': 0.0.11(zod@3.23.8)eventsource-parser: 1.1.2json-schema: 0.4.0jsondiffpatch: 0.6.0nanoid: 3.3.6secure-json-parse: 2.7.0solid-swr-store: 0.10.7(solid-js@1.8.16)(swr-store@0.10.6)sswr: 2.0.0(svelte@4.2.15)swr: 2.2.0(react@18.2.0)swr-store: 0.10.6swrv: 1.0.4(vue@3.4.23(typescript@5.4.5))zod-to-json-schema: 3.22.5(zod@3.23.8)optionalDependencies:openai: 4.38.1react: 18.2.0solid-js: 1.8.16svelte: 4.2.15vue: 3.4.23(typescript@5.4.5)zod: 3.23.8ajv@6.12.6:dependencies:209 unmodified linesansi-styles: 4.3.0supports-color: 7.2.0chalk@5.3.0: {}character-entities-legacy@1.1.4: {}character-entities@1.2.4: {}155 unmodified linesdidyoumean@1.2.2: {}diff-match-patch@1.0.5: {}diff@5.2.0: {}dir-glob@3.0.1:342 unmodified linesevents@3.3.0: {}eventsource-parser@1.1.2: {}extend@3.0.2: {}500 unmodified linesjson-schema-traverse@0.4.1: {}json-schema@0.4.0: {}json-stable-stringify-without-jsonify@1.0.1: {}json5@1.0.2:dependencies:minimist: 1.2.8jsondiffpatch@0.6.0:dependencies:'@types/diff-match-patch': 1.0.36chalk: 5.3.0diff-match-patch: 1.0.5jsx-ast-utils@3.3.5:dependencies:array-includes: 3.1.81030 unmodified linesdependencies:loose-envify: 1.4.0secure-json-parse@2.7.0: {}semver@6.3.1: {}semver@7.6.0:581 unmodified linesyocto-queue@0.1.0: {}zod-to-json-schema@3.22.5(zod@3.23.8):dependencies:zod: 3.23.8zod@3.23.8: {}zwitch@2.0.4: {}
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980import type { Config } from "tailwindcss"const config = {darkMode: ["class"],content: ['./pages/**/*.{ts,tsx}','./components/**/*.{ts,tsx}','./app/**/*.{ts,tsx}','./src/**/*.{ts,tsx}',],prefix: "",theme: {container: {center: true,padding: "2rem",screens: {"2xl": "1400px",},},extend: {colors: {border: "hsl(var(--border))",input: "hsl(var(--input))",ring: "hsl(var(--ring))",background: "hsl(var(--background))",foreground: "hsl(var(--foreground))",primary: {DEFAULT: "hsl(var(--primary))",foreground: "hsl(var(--primary-foreground))",},secondary: {DEFAULT: "hsl(var(--secondary))",foreground: "hsl(var(--secondary-foreground))",},destructive: {DEFAULT: "hsl(var(--destructive))",foreground: "hsl(var(--destructive-foreground))",},muted: {DEFAULT: "hsl(var(--muted))",foreground: "hsl(var(--muted-foreground))",},accent: {DEFAULT: "hsl(var(--accent))",foreground: "hsl(var(--accent-foreground))",},popover: {DEFAULT: "hsl(var(--popover))",foreground: "hsl(var(--popover-foreground))",},card: {DEFAULT: "hsl(var(--card))",foreground: "hsl(var(--card-foreground))",},},borderRadius: {lg: "var(--radius)",md: "calc(var(--radius) - 2px)",sm: "calc(var(--radius) - 4px)",},keyframes: {"accordion-down": {from: { height: "0" },to: { height: "var(--radix-accordion-content-height)" },},"accordion-up": {from: { height: "var(--radix-accordion-content-height)" },to: { height: "0" },},},animation: {"accordion-down": "accordion-down 0.2s ease-out","accordion-up": "accordion-up 0.2s ease-out",},},},plugins: [require("tailwindcss-animate")],} satisfies Configexport default config1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import type { Config } from 'tailwindcss';const config = {darkMode: ['class'],content: ['./pages/**/*.{ts,tsx}','./components/**/*.{ts,tsx}','./app/**/*.{ts,tsx}','./src/**/*.{ts,tsx}',],prefix: '',theme: {container: {center: true,padding: '2rem',screens: {'2xl': '1400px',},},extend: {colors: {border: 'hsl(var(--border))',input: 'hsl(var(--input))',ring: 'hsl(var(--ring))',background: 'hsl(var(--background))',foreground: 'hsl(var(--foreground))',primary: {DEFAULT: 'hsl(var(--primary))',foreground: 'hsl(var(--primary-foreground))',},secondary: {DEFAULT: 'hsl(var(--secondary))',foreground: 'hsl(var(--secondary-foreground))',},destructive: {DEFAULT: 'hsl(var(--destructive))',foreground: 'hsl(var(--destructive-foreground))',},muted: {DEFAULT: 'hsl(var(--muted))',foreground: 'hsl(var(--muted-foreground))',},accent: {DEFAULT: 'hsl(var(--accent))',foreground: 'hsl(var(--accent-foreground))',},popover: {DEFAULT: 'hsl(var(--popover))',foreground: 'hsl(var(--popover-foreground))',},card: {DEFAULT: 'hsl(var(--card))',foreground: 'hsl(var(--card-foreground))',},},borderRadius: {lg: 'var(--radius)',md: 'calc(var(--radius) - 2px)',sm: 'calc(var(--radius) - 4px)',},keyframes: {'accordion-down': {from: { height: '0' },to: { height: 'var(--radix-accordion-content-height)' },},'accordion-up': {from: { height: 'var(--radix-accordion-content-height)' },to: { height: '0' },},progress: {'0%': { transform: ' translateX(0) scaleX(0)' },'40%': { transform: 'translateX(0) scaleX(0.4)' },'100%': { transform: 'translateX(100%) scaleX(0.5)' },},},transformOrigin: {'left-right': '0% 50%',},animation: {'accordion-down': 'accordion-down 0.2s ease-out','accordion-up': 'accordion-up 0.2s ease-out',progress: 'progress 1s infinite linear',},},},plugins: [require('tailwindcss-animate')],} satisfies Config;export default config;
app/api/vision-agent/route.ts+2-3
app/chat/page.tsx+31-84
app/layout.tsx+1-1
components/Header.tsx+29
components/chat/ChatClient.tsx+39-13
components/chat/ChatMessage.tsx+2-7
components/chat/Composer.tsx+100-111
components/ui/Chip.tsx+1-1
components/ui/Icons.tsx+23-3
components/ui/Tooltip.tsx+1-1
lib/db/functions.ts+3-1
lib/hooks/useImageUpload.tsDeleted-38
components/chat/ImageSelector.tsx → lib/hooks/useMediaUpload.tsRenamed+30-49
lib/hooks/useScrollAnchor.tsx+4-4
lib/hooks/useVisionAgent.ts+5-21
package.json+1-1
pnpm-lock.yaml+102-11
tailwind.config.ts+48-39