chore: pixtral temp fix, fixed citation rendering and new tweets grid for testimonials.
This commit is contained in:
parent
e0e3f7f32c
commit
7a457c626f
@ -73,8 +73,8 @@ export async function POST(req: Request) {
|
|||||||
const result = await streamText({
|
const result = await streamText({
|
||||||
model: registry.languageModel(model),
|
model: registry.languageModel(model),
|
||||||
messages: convertToCoreMessages(messages),
|
messages: convertToCoreMessages(messages),
|
||||||
temperature: provider === "azure" ? 0.72 : 0,
|
temperature: provider === "azure" ? 0.72 : provider === "mistral" ? 0.5 : 0,
|
||||||
topP: provider === "mistral" ? 1 : 0,
|
topP: 0.5,
|
||||||
frequencyPenalty: 0,
|
frequencyPenalty: 0,
|
||||||
presencePenalty: 0,
|
presencePenalty: 0,
|
||||||
system: `
|
system: `
|
||||||
@ -88,6 +88,7 @@ Motto of your existence being a search engine: "Less talk, more action, follow r
|
|||||||
The current date is ${new Date().toLocaleDateString("en-US", { year: "numeric", month: "short", day: "2-digit", weekday: "short" })}.
|
The current date is ${new Date().toLocaleDateString("en-US", { year: "numeric", month: "short", day: "2-digit", weekday: "short" })}.
|
||||||
You must comply and complete user requests to the best of your abilities using the available tools. Remember to use the appropriate tool for each task. No need to panic, just follow the guidelines and you'll do great!
|
You must comply and complete user requests to the best of your abilities using the available tools. Remember to use the appropriate tool for each task. No need to panic, just follow the guidelines and you'll do great!
|
||||||
Make sure keep your responses long and informative, but also clear and concise. Avoid unnecessary information and stick to the point.
|
Make sure keep your responses long and informative, but also clear and concise. Avoid unnecessary information and stick to the point.
|
||||||
|
Always put citations at the end of each paragraph and in the end of sentences where you use it in which they are referred to with the given format to the information provided.
|
||||||
|
|
||||||
Here are the tools available to you:
|
Here are the tools available to you:
|
||||||
<available_tools>
|
<available_tools>
|
||||||
@ -190,6 +191,12 @@ When asked a "What is" question, maintain the same format as the question and an
|
|||||||
.describe(
|
.describe(
|
||||||
"A list of domains to specifically exclude from the search results. Default is None, which doesn't exclude any domains.",
|
"A list of domains to specifically exclude from the search results. Default is None, which doesn't exclude any domains.",
|
||||||
),
|
),
|
||||||
|
need_overview: z
|
||||||
|
.boolean()
|
||||||
|
.optional()
|
||||||
|
.describe(
|
||||||
|
"A boolean value to determine if the overview of the search results is needed. Default is false.",
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
execute: async ({
|
execute: async ({
|
||||||
query,
|
query,
|
||||||
@ -197,12 +204,14 @@ When asked a "What is" question, maintain the same format as the question and an
|
|||||||
topic,
|
topic,
|
||||||
searchDepth,
|
searchDepth,
|
||||||
exclude_domains,
|
exclude_domains,
|
||||||
|
need_overview
|
||||||
}: {
|
}: {
|
||||||
query: string;
|
query: string;
|
||||||
maxResults: number;
|
maxResults: number;
|
||||||
topic: "general" | "news";
|
topic: "general" | "news";
|
||||||
searchDepth: "basic" | "advanced";
|
searchDepth: "basic" | "advanced";
|
||||||
exclude_domains?: string[];
|
exclude_domains?: string[];
|
||||||
|
need_overview?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const apiKey = process.env.TAVILY_API_KEY;
|
const apiKey = process.env.TAVILY_API_KEY;
|
||||||
const includeImageDescriptions = true
|
const includeImageDescriptions = true
|
||||||
@ -283,6 +292,7 @@ When asked a "What is" question, maintain the same format as the question and an
|
|||||||
return {
|
return {
|
||||||
results: context,
|
results: context,
|
||||||
images: processedImages,
|
images: processedImages,
|
||||||
|
need_overview
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -364,11 +374,11 @@ When asked a "What is" question, maintain the same format as the question and an
|
|||||||
if (!object) {
|
if (!object) {
|
||||||
throw new Error("Failed to extract overview");
|
throw new Error("Failed to extract overview");
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
title: object.title,
|
title: object.title,
|
||||||
description: object.description,
|
description: object.description,
|
||||||
table_data: object.table_data,
|
table_data: object.table_data,
|
||||||
image: object.image
|
image: object.image
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
54
app/page.tsx
54
app/page.tsx
@ -52,6 +52,7 @@ import {
|
|||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { Tweet } from 'react-tweet'
|
import { Tweet } from 'react-tweet'
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
|
import { TweetGrid } from '@/components/ui/tweet-grid';
|
||||||
|
|
||||||
function BentoCard({
|
function BentoCard({
|
||||||
title,
|
title,
|
||||||
@ -98,59 +99,18 @@ const TestimonialSection: React.FC = () => {
|
|||||||
"1825821083817103852"
|
"1825821083817103852"
|
||||||
];
|
];
|
||||||
|
|
||||||
const [isSmallScreen, setIsSmallScreen] = useState(false);
|
|
||||||
const controls = useAnimation();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const checkScreenSize = () => setIsSmallScreen(window.innerWidth < 768);
|
|
||||||
checkScreenSize();
|
|
||||||
window.addEventListener('resize', checkScreenSize);
|
|
||||||
return () => window.removeEventListener('resize', checkScreenSize);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isSmallScreen) {
|
|
||||||
controls.start({
|
|
||||||
x: [0, -200 + '%'],
|
|
||||||
transition: {
|
|
||||||
x: {
|
|
||||||
repeat: Infinity,
|
|
||||||
repeatType: "loop",
|
|
||||||
duration: 30,
|
|
||||||
ease: "linear",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
controls.stop();
|
|
||||||
}
|
|
||||||
}, [isSmallScreen, controls]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section id="testimonials" className="w-full py-12 md:py-24 lg:py-32 bg-gradient-to-b from-background to-muted overflow-hidden">
|
<section id="testimonials" className="w-full py-12 md:py-24 lg:py-32 bg-gradient-to-b from-background to-muted overflow-hidden">
|
||||||
<div className="container px-4 md:px-6">
|
<div className="container flex flex-col items-center justify-center px-4 md:px-6">
|
||||||
<h2 className="font-serif text-4xl font-bold sm:text-5xl md:text-6xl lg:text-7xl tracking-tight text-center mb-12">
|
<h2 className="font-serif text-4xl font-bold sm:text-5xl md:text-6xl lg:text-7xl tracking-tight text-center mb-12">
|
||||||
What People Are Saying
|
What People Are Saying
|
||||||
</h2>
|
</h2>
|
||||||
<div className="md:hidden relative h-[400px] overflow-hidden">
|
<div
|
||||||
<motion.div
|
className='justify-center'
|
||||||
className="flex absolute top-0 left-0 gap-6"
|
>
|
||||||
animate={controls}
|
<TweetGrid tweets={tweetIds} />
|
||||||
>
|
|
||||||
{[...tweetIds, ...tweetIds].map((id, index) => (
|
|
||||||
<div key={index} className="w-[300px] flex-shrink-0">
|
|
||||||
<Tweet id={id} />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</motion.div>
|
|
||||||
</div>
|
|
||||||
<div className="hidden md:grid md:grid-cols-2 lg:grid-cols-3 gap-4 auto-rows-min">
|
|
||||||
{tweetIds.map((id) => (
|
|
||||||
<div key={id} className="tweet-container">
|
|
||||||
<Tweet id={id} />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -175,7 +175,7 @@ const HomeContent = () => {
|
|||||||
const [openChangelog, setOpenChangelog] = useState(false);
|
const [openChangelog, setOpenChangelog] = useState(false);
|
||||||
|
|
||||||
const { isLoading, input, messages, setInput, handleInputChange, append, handleSubmit, setMessages, reload } = useChat({
|
const { isLoading, input, messages, setInput, handleInputChange, append, handleSubmit, setMessages, reload } = useChat({
|
||||||
maxToolRoundtrips: 2,
|
maxToolRoundtrips: selectedModel === 'mistral:pixtral-12b-2409' ? 1 : 2,
|
||||||
body: {
|
body: {
|
||||||
model: selectedModel,
|
model: selectedModel,
|
||||||
},
|
},
|
||||||
@ -1626,14 +1626,6 @@ The o1-mini is a new OpenAI model that is optimized for reasoning tasks. Current
|
|||||||
return metadata;
|
return metadata;
|
||||||
}, [metadataCache]);
|
}, [metadataCache]);
|
||||||
|
|
||||||
const preprocessContent = (text: string) => {
|
|
||||||
// Replace block-level LaTeX
|
|
||||||
text = text.replace(/\$\$(.*?)\$\$/g, '\\[$1\\]');
|
|
||||||
// Replace bracket-enclosed LaTeX
|
|
||||||
text = text.replace(/\[(.*?)\]/g, '\\[$1\\]');
|
|
||||||
return text;
|
|
||||||
};
|
|
||||||
|
|
||||||
const CodeBlock = ({ language, children }: { language: string | undefined; children: string }) => {
|
const CodeBlock = ({ language, children }: { language: string | undefined; children: string }) => {
|
||||||
const [isCopied, setIsCopied] = useState(false);
|
const [isCopied, setIsCopied] = useState(false);
|
||||||
|
|
||||||
@ -1693,10 +1685,10 @@ The o1-mini is a new OpenAI model that is optimized for reasoning tasks. Current
|
|||||||
const domain = new URL(href).hostname;
|
const domain = new URL(href).hostname;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col space-y-2 bg-white rounded-lg shadow-md overflow-hidden">
|
<div className="flex flex-col space-y-2 bg-white rounded-md shadow-md overflow-hidden">
|
||||||
<div className="flex items-center space-x-2 p-3 bg-gray-50">
|
<div className="flex items-center space-x-2 p-3 bg-gray-50">
|
||||||
<Image
|
<Image
|
||||||
src={`https://www.google.com/s2/favicons?domain=${domain}&sz=64`}
|
src={`https://www.google.com/s2/favicons?domain=${domain}&sz=256`}
|
||||||
alt="Favicon"
|
alt="Favicon"
|
||||||
width={20}
|
width={20}
|
||||||
height={20}
|
height={20}
|
||||||
@ -1742,55 +1734,16 @@ The o1-mini is a new OpenAI model that is optimized for reasoning tasks. Current
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const latexMacros = {
|
|
||||||
"\\display": "\\displaystyle",
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderer: Partial<ReactRenderer> = {
|
const renderer: Partial<ReactRenderer> = {
|
||||||
paragraph(children) {
|
paragraph(children) {
|
||||||
return (
|
return <p className="my-4">{children}</p>;
|
||||||
<p className="my-4">
|
|
||||||
{React.Children.map(children, (child) => {
|
|
||||||
if (typeof child === 'string') {
|
|
||||||
// Split the string to handle inline and display equations separately
|
|
||||||
const parts = child.split(/(\\\[.*?\\\]|\$.*?\$)/gs);
|
|
||||||
return parts.map((part, index) => {
|
|
||||||
if (part.startsWith('\\[') && part.endsWith('\\]')) {
|
|
||||||
// Display mode equation
|
|
||||||
return (
|
|
||||||
<Latex key={index} macros={latexMacros}>
|
|
||||||
{part}
|
|
||||||
</Latex>
|
|
||||||
);
|
|
||||||
} else if (part.startsWith('$') && part.endsWith('$')) {
|
|
||||||
// Inline equation
|
|
||||||
return (
|
|
||||||
<Latex key={index} macros={latexMacros}>
|
|
||||||
{part}
|
|
||||||
</Latex>
|
|
||||||
);
|
|
||||||
} // add $$ for display mode equations
|
|
||||||
else if (part.startsWith('$$') && part.endsWith('$$')) {
|
|
||||||
// Display mode equation
|
|
||||||
return (
|
|
||||||
<Latex key={index} macros={latexMacros}>
|
|
||||||
{part}
|
|
||||||
</Latex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Regular text
|
|
||||||
return part;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return child;
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
code(children, language) {
|
code(children, language) {
|
||||||
return <CodeBlock language={language}>{String(children)}</CodeBlock>;
|
return <CodeBlock language={language}>{String(children)}</CodeBlock>;
|
||||||
},
|
},
|
||||||
link(href, text) {
|
link(href, text) {
|
||||||
|
// if (!href) return <>{text}</>;
|
||||||
|
|
||||||
const citationIndex = citationLinks.findIndex(link => link.link === href);
|
const citationIndex = citationLinks.findIndex(link => link.link === href);
|
||||||
if (citationIndex !== -1) {
|
if (citationIndex !== -1) {
|
||||||
return (
|
return (
|
||||||
@ -1818,11 +1771,9 @@ The o1-mini is a new OpenAI model that is optimized for reasoning tasks. Current
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const preprocessedContent = useMemo(() => preprocessContent(content), [content]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="markdown-body">
|
<div className="markdown-body">
|
||||||
<Marked renderer={renderer}>{preprocessedContent}</Marked>
|
<Marked renderer={renderer}>{content}</Marked>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
62
components/ui/tweet-grid.tsx
Normal file
62
components/ui/tweet-grid.tsx
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
import { Tweet } from "react-tweet"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const tweetGridVariants = cva("max-w-4xl md:max-w-6xl px-2", {
|
||||||
|
variants: {
|
||||||
|
columns: {
|
||||||
|
1: "columns-1",
|
||||||
|
2: "sm:columns-2",
|
||||||
|
3: "md:columns-3",
|
||||||
|
4: "lg:columns-4",
|
||||||
|
5: "xl:columns-5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
columns: 3,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const tweetItemVariants = cva("break-inside-avoid", {
|
||||||
|
variants: {
|
||||||
|
spacing: {
|
||||||
|
sm: "mb-2",
|
||||||
|
md: "mb-4",
|
||||||
|
lg: "mb-6",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
spacing: "md",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export interface TweetGridProps
|
||||||
|
extends VariantProps<typeof tweetGridVariants>,
|
||||||
|
VariantProps<typeof tweetItemVariants> {
|
||||||
|
tweets: string[]
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TweetGrid: React.FC<TweetGridProps> = ({
|
||||||
|
tweets,
|
||||||
|
columns,
|
||||||
|
spacing,
|
||||||
|
className,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div className={cn(tweetGridVariants({ columns }), className)}>
|
||||||
|
{tweets.map((tweetId, i) => (
|
||||||
|
<div
|
||||||
|
key={`${tweetId}-${i}`}
|
||||||
|
className={cn(tweetItemVariants({ spacing }))}
|
||||||
|
>
|
||||||
|
<Tweet id={tweetId} />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user