diff --git a/README.md b/README.md index f645b99..dcbe366 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ ## Todos v1.5 -- [ ] Implement design changes on the pdf page: avatars + chatbox scroll -- [ ] Add header to the pdf page to be able to go back to the dashboard -- [ ] Add my own google cloud project to Clerk and create a production instance +- [ ] Implement design changes on the pdf page: chatbot scroll - [ ] Make sure it's fully responsive on mobile +- [ ] Implement sources like perplexity with more info +- [ ] Make some changes to the default tailwind `prose` +- [ ] Add my own google cloud project to Clerk and create a production instance - [ ] Spin up good README + tweet ## Future Todos @@ -13,6 +14,7 @@ - [ ] Add an initial message with sample questions or just add them as bubbles - [ ] Add a trash icon for folks to delete PDFs and implement delete functionality - [ ] Add an option to get answers as lists or paragraphs +- [ ] Save chats for each user to get back to later - [ ] Use an observability tool to better understand how people are using the site - [ ] Clean up and customize how the PDF viewer looks - [ ] Bring up a message to compress PDFs if they're beyond 10MB or accept more diff --git a/app/document/[id]/document-client.tsx b/app/document/[id]/document-client.tsx index 37134ad..14ef07d 100644 --- a/app/document/[id]/document-client.tsx +++ b/app/document/[id]/document-client.tsx @@ -18,8 +18,10 @@ import { useChat } from 'ai/react'; export default function DocumentClient({ currentDoc, + userImage, }: { currentDoc: Document; + userImage?: string; }) { const toolbarPluginInstance = toolbarPlugin(); const pageNavigationPluginInstance = pageNavigationPlugin(); @@ -82,6 +84,8 @@ export default function DocumentClient({ } }; + let userProfilePic = userImage ? userImage : '/profile-icon.png'; + return (
@@ -112,88 +116,76 @@ export default function DocumentClient({
+ {messages.length === 0 && ( +
+ Ask your first question below! +
+ )} {messages.map((message, index) => { const sources = sourcesForMessages[index] || undefined; const isLastMessage = !isLoading && index === messages.length - 1; const previousMessages = index !== messages.length - 1; - let icon; - let className; - if (message.role === 'assistant') { - icon = ( - AI - ); - className = 'bg-gray-100 p-6 text-black animate'; - } else { - icon = ( - Me - ); - // The latest message sent by the user will be animated while waiting for a response - className = - isLoading && index === messages.length - 1 - ? 'p-6 text-black flex animate-pulse bg-gray-100' - : 'bg-white p-6 text-black flex'; - } return (
-
- {icon} -
+
+
+ profile image {message.content} - {/* Display the sources */} - - {(isLastMessage || previousMessages) && sources && ( -
- {sources - .filter( - (source: any, index: number, self: any) => { - const pageNumber = - source.metadata['loc.pageNumber']; - // Check if the current pageNumber is the first occurrence in the array - return ( - self.findIndex( - (s: any) => - s.metadata['loc.pageNumber'] === - pageNumber, - ) === index - ); - }, - ) - .map((source: any) => ( - - ))} -
- )}
+ {/* Display the sources */} + {(isLastMessage || previousMessages) && sources && ( +
+ {sources + .filter((source: any, index: number, self: any) => { + const pageNumber = + source.metadata['loc.pageNumber']; + // Check if the current pageNumber is the first occurrence in the array + return ( + self.findIndex( + (s: any) => + s.metadata['loc.pageNumber'] === pageNumber, + ) === index + ); + }) + .map((source: any) => ( + + ))} +
+ )}
); diff --git a/app/document/[id]/page.tsx b/app/document/[id]/page.tsx index 36fd8f0..5ccb3af 100644 --- a/app/document/[id]/page.tsx +++ b/app/document/[id]/page.tsx @@ -19,7 +19,7 @@ export default async function Page({ params }: { params: { id: string } }) { return (
- +
); } diff --git a/next.config.js b/next.config.js index fc5ec08..9cefd32 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,16 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'img.clerk.com', + port: '', + pathname: '/*', + }, + ], + }, experimental: { esmExternals: 'loose', }, diff --git a/public/bot-icon.png b/public/bot-icon.png new file mode 100644 index 0000000..446f6bc Binary files /dev/null and b/public/bot-icon.png differ diff --git a/public/bot-image.png b/public/bot-image.png deleted file mode 100644 index eddc752..0000000 Binary files a/public/bot-image.png and /dev/null differ diff --git a/public/profile-icon.png b/public/profile-icon.png new file mode 100644 index 0000000..696ab67 Binary files /dev/null and b/public/profile-icon.png differ