Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: make summary publicly available
Marc Seitz04cfe7befcc8
diff --git a/components/chat/chat-input.tsx b/components/chat/chat-input.tsxindex e0a3b8ca..82e328aa 100644--- a/components/chat/chat-input.tsx+++ b/components/chat/chat-input.tsx@@ -33,9 +33,9 @@ export function ChatInput({}, [status]);return (- <div className="fixed inset-x-0 bottom-0">+ <div className="relative inset-x-0 bottom-0"><div className="mx-auto sm:max-w-3xl sm:px-4">- <div className="space-y-4 bg-background px-4 py-4 shadow-lg md:py-4">+ <div className="space-y-4 bg-background px-4 py-4 md:py-4"><form onSubmit={submitMessage} ref={formRef}><div className="relative flex max-h-60 w-full flex-col overflow-hidden bg-background pr-8 rounded-xl ring-1 ring-muted-foreground/50 sm:pr-12 focus-within:ring-1 focus-within:ring-foreground"><Textareadiff --git a/components/chat/chat.tsx b/components/chat/chat.tsxindex a7a9d342..7ac7c0bb 100644--- a/components/chat/chat.tsx+++ b/components/chat/chat.tsx@@ -14,8 +14,9 @@ import { useEffect, useState } from "react";export interface ChatProps extends React.ComponentProps<"div"> {initialMessages: Message[];- threadId: string;- firstPage: string;+ threadId?: string;+ firstPage?: string;+ isPublic?: boolean;}export function Chat({@@ -23,6 +24,7 @@ export function Chat({threadId,firstPage,className,+ isPublic,}: ChatProps) {const {status,@@ -34,6 +36,9 @@ export function Chat({} = useAssistant({api: "/api/assistants/chat",threadId: threadId,+ body: {+ isPublic: isPublic,+ },});const [combinedMessages, setCombinedMessages] = useState<Message[]>([]);@@ -56,11 +61,18 @@ export function Chat({return (<>- <div className={cn("pb-[100px] pt-24", className)}>+ <div+ className={cn(+ "pb-[20px] pt-24 h-[calc(100vh-96px)] relative overflow-y-auto",+ className,+ )}+ >{combinedMessages.length ? (<><ChatList messages={combinedMessages} status={status} />- <ChatScrollAnchor trackVisibility={isLoading} />+ {!isPublic ? (+ <ChatScrollAnchor trackVisibility={isLoading} />+ ) : null}</>) : (<EmptyScreendiff --git a/components/chat/empty-screen.tsx b/components/chat/empty-screen.tsxindex 56d46f95..0b6e6430 100644--- a/components/chat/empty-screen.tsx+++ b/components/chat/empty-screen.tsx@@ -1,5 +1,6 @@import { Button } from "@/components/ui/button";import Image from "next/image";+import Sparkle from "../shared/icons/sparke";const exampleMessages = [{@@ -26,7 +27,7 @@ export function EmptyScreen({setInput,handleInputChange,}: {- firstPage: string;+ firstPage?: string;setInput: (input: string) => void;handleInputChange: (e: any) => void;}) {@@ -40,19 +41,36 @@ export function EmptyScreen({<><div className="mx-auto w-1/2 md:w-1/3"><div className="flex items-center justify-center">- <Image- src={firstPage}- width={768}- height={100}- className="object-contain rounded-md ring-1 ring-gray-700"- alt="First page of the document"- />+ {firstPage ? (+ <Image+ src={firstPage}+ width={768}+ height={100}+ className="object-contain rounded-md ring-1 ring-gray-700"+ alt="First page of the document"+ />+ ) : (+ <div className="flex items-center justify-center rounded-md w-full">+ <p className="inline-flex text-xl">+ Chat with{" "}+ <span className="inline-flex items-center mx-1 space-x-1">+ <span className="text-xl font-bold tracking-tighter ">+ Papermark+ </span>+ 's+ </span>+ pitchdeck+ </p>+ </div>+ )}</div>+<div className="flex justify-center text-lg mt-4">What would you like to know?</div></div>- <div className="mx-auto max-w-2xl px-4 fixed bottom-28 inset-x-0">++ <div className="mx-auto max-w-2xl px-4 absolute bottom-0 inset-x-0"><div className="grid grid-cols-1 sm:grid-cols-2 gap-2">{exampleMessages.map((message, index) => (<Buttondiff --git a/components/documents/document-card.tsx b/components/documents/document-card.tsxindex 437f118f..fadf8d48 100644--- a/components/documents/document-card.tsx+++ b/components/documents/document-card.tsx@@ -103,7 +103,7 @@ export default function DocumentsCard({</div><div className="flex flex-row space-x-2">- {document.type === "notion" ? (+ {document.type !== "notion" ? (<buttononClick={(e) => {e.stopPropagation();@@ -111,8 +111,8 @@ export default function DocumentsCard({}}className="group/button flex items-center z-10 space-x-1 rounded-md ring-1 ring-gray-200 dark:ring-gray-700 px-2 py-0.5 transition-all duration-75 hover:scale-105 active:scale-95">- <PapermarkSparkle className="h-4 w-4 text-gray-400 group-hover/row:text-foreground group-hover/row:animate-pulse group-hover/button:text-white group-hover/button:animate-none" />- <span className="whitespace-nowrap text-sm ml-1 hidden sm:inline-block text-gray-400 group-hover/button:text-white">+ <PapermarkSparkle className="h-4 w-4 text-gray-400 group-hover/row:text-foreground group-hover/row:animate-pulse group-hover/button:text-foreground group-hover/button:animate-none" />+ <span className="whitespace-nowrap text-sm ml-1 hidden sm:inline-block text-gray-400 group-hover/button:text-foreground">AI Assistant</span></button>diff --git a/components/web/assistant/public-chat.tsx b/components/web/assistant/public-chat.tsxnew file mode 100644index 00000000..0d925d95--- /dev/null+++ b/components/web/assistant/public-chat.tsx@@ -0,0 +1,15 @@+import { type Message } from "ai/react";+import { Chat } from "@/components/chat/chat";++export default function ChatPage() {+ const initialMessages: Message[] = [];+ return (+ <>+ <Chat+ initialMessages={initialMessages}+ isPublic={true}+ className="h-[calc(100vh-180px)]"+ />+ </>+ );+}diff --git a/pages/api/assistants/chat.ts b/pages/api/assistants/chat.tsindex 7b2a736d..c21906a3 100644--- a/pages/api/assistants/chat.ts+++ b/pages/api/assistants/chat.ts@@ -15,28 +15,34 @@ export const config = {export default async function POST(req: Request) {// Parse the request bodyconst input: {- threadId: string;+ threadId: string | null;message: string;+ isPublic: boolean | null;} = await req.json();+ // create a threadId if one wasn't provided+ const threadId = input.threadId ?? (await openai.beta.threads.create()).id;+// Add a message to the thread- const createdMessage = await openai.beta.threads.messages.create(- input.threadId,- {- role: "user",- content: input.message,- },- );+ const createdMessage = await openai.beta.threads.messages.create(threadId, {+ role: "user",+ content: input.message,+ });++ // select the assistantId based on the isPublic flag+ const assistantId = input.isPublic+ ? (process.env.OAI_PUBLIC_ASSISTANT_ID as string)+ : (process.env.OAI_ASSISTANT_ID as string);return experimental_AssistantResponse({- threadId: input.threadId,+ threadId,messageId: createdMessage.id,},async ({ threadId, sendMessage }) => {// Run the assistant on the threadconst run = await openai.beta.threads.runs.create(threadId, {- assistant_id: process.env.OAI_ASSISTANT_ID!,+ assistant_id: assistantId!,});async function waitForRun(run: OpenAI.Beta.Threads.Runs.Run) {diff --git a/pages/launch-week.tsx b/pages/launch-week.tsxindex 0f828319..d1ed9164 100644--- a/pages/launch-week.tsx+++ b/pages/launch-week.tsx@@ -4,6 +4,7 @@ import Hero from "@/components/web/launch/hero";import Grid from "@/components/web/launch/daysgrid";import CTA from "@/components/web/launch/cta";import Head from "next/head";+import ChatPage from "@/components/web/assistant/public-chat";export default function LaunchWeek() {return (@@ -32,6 +33,9 @@ export default function LaunchWeek() {<Hero /><Grid /><CTA />+ <div className="relative bg-background">+ <ChatPage />+ </div></div></div><Footer />