feat: add navbar and fix system prompt

This commit is contained in:
zaidmukaddam 2024-08-15 22:14:25 +05:30
parent a70f15a7b2
commit a45f5d09ea
3 changed files with 50 additions and 3 deletions

View File

@ -50,6 +50,7 @@ export async function POST(req: Request) {
.replace(/(\w+), (\w+) (\d+), (\d+)/, "$4-$2-$3 ($1)") + .replace(/(\w+), (\w+) (\d+), (\d+)/, "$4-$2-$3 ($1)") +
"." + "." +
"Rules for the response:\n" + "Rules for the response:\n" +
"Never use tags like <response>, <result> or <answer> in the response." +
"Use a story telling format in your response, like a news article ALWAYS! This is for all tools except programming!" + "Use a story telling format in your response, like a news article ALWAYS! This is for all tools except programming!" +
"Never start with 'based on the search results,...' EVER! Always start with the information you found like an article!" + "Never start with 'based on the search results,...' EVER! Always start with the information you found like an article!" +
"Never use the heading format in your response!." + "Never use the heading format in your response!." +

5
app/new/page.tsx Normal file
View File

@ -0,0 +1,5 @@
import { redirect } from 'next/navigation'
export default async function NewPage() {
redirect('/')
}

View File

@ -11,6 +11,7 @@ React,
useMemo useMemo
} from 'react'; } from 'react';
import ReactMarkdown, { Components } from 'react-markdown'; import ReactMarkdown, { Components } from 'react-markdown';
import { useRouter } from 'next/navigation';
import remarkGfm from 'remark-gfm'; import remarkGfm from 'remark-gfm';
import { useChat } from 'ai/react'; import { useChat } from 'ai/react';
import { ToolInvocation } from 'ai'; import { ToolInvocation } from 'ai';
@ -37,6 +38,8 @@ import {
Loader2, Loader2,
User2, User2,
Edit2, Edit2,
RefreshCw,
Heart,
} from 'lucide-react'; } from 'lucide-react';
import { import {
HoverCard, HoverCard,
@ -93,6 +96,7 @@ import {
export const maxDuration = 60; export const maxDuration = 60;
export default function Home() { export default function Home() {
const router = useRouter();
const inputRef = useRef<HTMLInputElement>(null); const inputRef = useRef<HTMLInputElement>(null);
const [lastSubmittedQuery, setLastSubmittedQuery] = useState(""); const [lastSubmittedQuery, setLastSubmittedQuery] = useState("");
const [hasSubmitted, setHasSubmitted] = useState(false); const [hasSubmitted, setHasSubmitted] = useState(false);
@ -139,9 +143,13 @@ export default function Home() {
const copyToClipboard = async (text: string) => { const copyToClipboard = async (text: string) => {
try { try {
await navigator.clipboard.writeText(text); if (navigator.clipboard && navigator.clipboard.writeText) {
toast.success("Copied to clipboard"); await navigator.clipboard.writeText(text);
return true; toast.success("Copied to clipboard");
return true;
} else {
throw new Error("Clipboard API not available");
}
} catch (error) { } catch (error) {
console.error('Failed to copy:', error); console.error('Failed to copy:', error);
toast.error("Failed to copy"); toast.error("Failed to copy");
@ -770,8 +778,41 @@ export default function Home() {
"Explain Claude 3.5 Sonnet" "Explain Claude 3.5 Sonnet"
]; ];
const Navbar = () => (
<div className="fixed top-0 left-0 right-0 z-50 flex justify-between items-center p-4 bg-background">
<Button
variant="outline"
size="sm"
onClick={() => router.push('/')}
className="flex items-center space-x-2"
>
<RefreshCw className="h-4 w-4" />
<span>New</span>
</Button>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Button
size="sm"
onClick={() => window.open("https://github.com/sponsors/zaidmukaddam", "_blank")}
className="flex items-center space-x-2"
>
<Heart className="h-4 w-4 text-red-500" />
<span>Sponsor</span>
</Button>
</TooltipTrigger>
<TooltipContent>
<p>Sponsor this project on GitHub</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
);
return ( return (
<div className="flex flex-col font-sans items-center min-h-screen p-2 sm:p-4 bg-background text-foreground transition-all duration-500"> <div className="flex flex-col font-sans items-center min-h-screen p-2 sm:p-4 bg-background text-foreground transition-all duration-500">
<Navbar />
<div className={`w-full max-w-[90%] sm:max-w-2xl space-y-4 sm:space-y-6 p-1 ${hasSubmitted ? 'mt-16 sm:mt-20' : 'mt-[15vh] sm:mt-[20vh]'}`}> <div className={`w-full max-w-[90%] sm:max-w-2xl space-y-4 sm:space-y-6 p-1 ${hasSubmitted ? 'mt-16 sm:mt-20' : 'mt-[15vh] sm:mt-[20vh]'}`}>
<motion.div <motion.div
initial={false} initial={false}