Skip to content

Commit

Permalink
fixed PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
subhadeeproy3902 committed Dec 20, 2024
1 parent 79d5beb commit 59e2367
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 36 deletions.
8 changes: 3 additions & 5 deletions app/api/getAnswer/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function POST(request: Request) {
);

const mainAnswerPrompt = `
Given a user question and some context, please write a detailed, structured, and professional report on the topic based on the context provided. You will be given a set of related contexts to the question, each starting with a reference number like [[citation:x]], where x is a number. Use these contexts to create an in-depth, accurate, and well-organized report.
Given a user question and some context, please write a detailed, structured, and professional report on the topic based on the context provided. You will be given a set of related contexts to the question, each starting with a reference number like 'x.', where x is a number. Use these contexts to create an in-depth, accurate, and well-organized report.
Your report should be in Markdown format and should dynamically include appropriate sections based on the topic and context. The sections must:
- Be logical and relevant to the topic.
Expand All @@ -69,7 +69,7 @@ export async function POST(request: Request) {
- Key Findings
- Future Scope
- Conclusion
2. **References**: Use a separate section at the end to list references cited in the report, using the citation format [[citation:x]].
2. **References**: Use a separate section at the end to list references cited in the report, using the citation format 'x.'.
Ensure the report is:
- Expertly written with a professional tone.
Expand All @@ -82,9 +82,7 @@ export async function POST(request: Request) {
Here are the set of contexts:
<contexts>
${finalResults.map(
(result, index) => `[[citation:${index}]] ${result.fullContent} \n\n`,
)}
${finalResults.map((result, index) => `${index}. ${result.fullContent} \n\n`)}
</contexts>
Remember, the report must read like a professional document with appropriate Markdown formatting. Use sections and subsections thoughtfully to create a logical flow. Here is the user question:
Expand Down
6 changes: 6 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ h4,
h5,
h6 {
font-weight: 800;
line-height: initial;
}

.markdown h2 {
Expand Down Expand Up @@ -135,6 +136,11 @@ h6 {
margin-bottom: 5px;
}

.markdown ol li, .markdown menu li {
list-style-type: decimal;
margin-bottom: 5px;
}

.markdown ul li {
list-style-type: disc;
margin-bottom: 5px;
Expand Down
10 changes: 5 additions & 5 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const inter = Lexend({ subsets: ["latin"] });
let title = "Turbo Seek – AI Search Engine";
let description =
"Search smarter and faster with our open source AI search engine";
let url = "https://turboseek.io/";
let ogimage = "https://turboseek.io/og-image.png";
let sitename = "TurboSeek.io";
let url = "https://SwiftSeek.io/";
let ogimage = "https://SwiftSeek.io/og-image.png";
let sitename = "SwiftSeek.io";

export const metadata: Metadata = {
metadataBase: new URL(url),
Expand Down Expand Up @@ -44,10 +44,10 @@ export default function RootLayout({
return (
<html lang="en">
<head>
<PlausibleProvider domain="turboseek.io" />
<PlausibleProvider domain="SwiftSeek.io" />
</head>
<body
className={`${inter.className} flex min-h-screen flex-col justify-between`}
className={`${inter.className} overflow-x-hidden flex min-h-screen relative flex-col justify-between bg-orange-50`}
>
{children}
</body>
Expand Down
11 changes: 10 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,17 @@ export default function Home() {

return (
<>
<div className="absolute h-screen w-full overflow-hidden">
<div className="relative h-screen w-full overflow-hidden">
<div className="animate-blob absolute -left-4 top-0 h-72 w-72 rounded-full bg-orange-300 opacity-30 mix-blend-multiply blur-3xl filter"></div>
<div className="animate-blob animation-delay-2000 absolute -right-4 top-0 h-72 w-72 rounded-full bg-yellow-300 opacity-30 mix-blend-multiply blur-3xl filter"></div>
<div className="animate-blob animation-delay-4000 absolute -bottom-8 left-1/2 h-72 w-72 -translate-x-1/2 transform rounded-full bg-pink-300 opacity-30 mix-blend-multiply blur-3xl filter"></div>
</div>
</div>

<Header />
<main className="h-full px-4 pb-4">

<main className="h-full px-4 pb-4 z-50">
{!showResult && (
<Hero
promptValue={promptValue}
Expand Down
Binary file modified bun.lockb
Binary file not shown.
31 changes: 17 additions & 14 deletions components/Answer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import Image from "next/image";
import { Toaster, toast } from "react-hot-toast";
import Markdown from "react-markdown";
import { usePDF } from "react-to-pdf";
import { Margin, usePDF } from "react-to-pdf";

export default function Answer({ answer }: { answer: string }) {

const { toPDF, targetRef } = usePDF({
filename: "report.pdf",
page: {
margin: Margin.LARGE,
format: "letter",
},
});

return (
Expand Down Expand Up @@ -75,18 +78,18 @@ export default function Answer({ answer }: { answer: string }) {
<div className="w-full whitespace-pre-wrap text-base font-light leading-[152.5%] text-black">
{answer ? (
<>
<div
ref={targetRef}
className="markdown whitespace-pre-wrap p-4 md:p-8"
>
<Markdown className="report">{answer.trim()}</Markdown>
</div>
<button
className="bg-[#FFD700] text-black font-bold uppercase text-xs py-2 px-4 rounded-lg"
onClick={() => toPDF()}
>
Download Report
</button>
<div
ref={targetRef}
className="markdown whitespace-pre text-wrap p-4 md:p-8"
>
<Markdown className="report">{answer.trim()}</Markdown>
</div>
<button
className="rounded-lg bg-[#FFD700] px-4 py-2 text-xs font-bold uppercase text-black"
onClick={() => toPDF()}
>
Download Report
</button>
</>
) : (
<div className="flex w-full flex-col gap-2">
Expand Down
6 changes: 3 additions & 3 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const Footer = () => {
<a href="/" className="flex items-center gap-2.5">
<Image
unoptimized
src="/img/logo.svg"
src="/logo.png"
alt="footer"
width={31}
height={30}
/>
<span className="text-base font-medium leading-[normal]">
TurboSeek.io
SwiftSeek.io
</span>
</a>
<div className="flex items-center gap-3">
Expand All @@ -27,7 +27,7 @@ const Footer = () => {
height={15}
/>
</Link>
<Link href={"https://github.com/Nutlope/turboseek"} target="_blank">
<Link href={"https://github.com/Nutlope/SwiftSeek"} target="_blank">
<Image
unoptimized
src={"/img/github-footer.svg"}
Expand Down
4 changes: 2 additions & 2 deletions components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import Image from "next/image";

const Header = () => {
return (
<div className="container h-[60px] px-4 lg:h-[80px] lg:px-0">
<div className="container px-4 lg:px-0 mt-16">
<div className="grid h-full grid-cols-12">
<div className="col-span-5"></div>
<div className="col-span-2 flex items-center justify-center">
<a href="/">
<Image
unoptimized
src="/img/logo.svg"
src="/logo.png"
alt="logo"
width={40}
height={39}
Expand Down
12 changes: 6 additions & 6 deletions components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ const Hero: FC<THeroProps> = ({
return (
<div className="flex flex-col items-center justify-center">
<a
className="mb-4 inline-flex h-7 shrink-0 items-center gap-[9px] rounded-[50px] border-[0.5px] border-solid border-[#E6E6E6] bg-white px-3 py-4 shadow-[0px_1px_1px_0px_rgba(0,0,0,0.25)]"
className="mb-4 inline-flex h-7 shrink-0 items-center gap-[9px] rounded-[50px] border-[0.5px] border-solid border-[#ff9232] bg-orange-100/20 px-4 py-4 shadow-[0px_1px_1px_0px_rgba(0,0,0,0.25)]"
href="https://www.together.ai/"
target="_blank"
>
<Image
unoptimized
src="/img/together-ai.svg"
src="/logo.png"
alt="hero"
width={18}
height={18}
width={20}
height={20}
/>
<span className="text-center text-base font-light leading-[normal] text-[#1B1B16]">
Powered by Together AI
</span>
</a>
<h2 className="bg-custom-gradient bg-clip-text pb-7 pt-2 text-center text-3xl font-semibold leading-[normal] lg:text-[64px]">
<h2 className="bg-gradient-to-r from-amber-500 via-orange-600 to-amber-500 bg-clip-text text-transparent pb-7 pt-2 opacity-100 saturate-200 text-center text-3xl font-semibold leading-[normal] lg:text-[64px] drop-shadow-2xl">
Search smarter & faster
</h2>

Expand Down Expand Up @@ -76,7 +76,7 @@ const Hero: FC<THeroProps> = ({
Fully open source!{" "}
<span className="text-sm font-medium underline">
<a
href="https://github.com/Nutlope/turboseek"
href="https://github.com/Nutlope/SwiftSeek"
target="_blank"
rel="noopener noreferrer"
>
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"dependencies": {
"@mozilla/readability": "^0.5.0",
"eventsource-parser": "^1.1.2",
"html2canvas": "^1.4.1",
"jsdom": "^24.1.0",
"jspdf": "^2.5.2",
"next": "14.2.3",
"next-plausible": "^3.12.0",
"react": "^18",
Expand Down
Binary file added public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 59e2367

Please sign in to comment.