From 7a457c626fb382de1d60af412a65955640b6fb06 Mon Sep 17 00:00:00 2001 From: zaidmukaddam Date: Thu, 19 Sep 2024 22:49:36 +0530 Subject: [PATCH] chore: pixtral temp fix, fixed citation rendering and new tweets grid for testimonials. --- app/api/chat/route.ts | 24 ++++++++++---- app/page.tsx | 54 ++++--------------------------- app/search/page.tsx | 63 ++++-------------------------------- components/ui/tweet-grid.tsx | 62 +++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 110 deletions(-) create mode 100644 components/ui/tweet-grid.tsx diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 7b2feed..39b8b6f 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -73,8 +73,8 @@ export async function POST(req: Request) { const result = await streamText({ model: registry.languageModel(model), messages: convertToCoreMessages(messages), - temperature: provider === "azure" ? 0.72 : 0, - topP: provider === "mistral" ? 1 : 0, + temperature: provider === "azure" ? 0.72 : provider === "mistral" ? 0.5 : 0, + topP: 0.5, frequencyPenalty: 0, presencePenalty: 0, 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" })}. 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. +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: @@ -190,6 +191,12 @@ When asked a "What is" question, maintain the same format as the question and an .describe( "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 ({ query, @@ -197,12 +204,14 @@ When asked a "What is" question, maintain the same format as the question and an topic, searchDepth, exclude_domains, + need_overview }: { query: string; maxResults: number; topic: "general" | "news"; searchDepth: "basic" | "advanced"; exclude_domains?: string[]; + need_overview?: boolean; }) => { const apiKey = process.env.TAVILY_API_KEY; const includeImageDescriptions = true @@ -283,6 +292,7 @@ When asked a "What is" question, maintain the same format as the question and an return { results: context, 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) { throw new Error("Failed to extract overview"); } - return { - title: object.title, - description: object.description, - table_data: object.table_data, - image: object.image + return { + title: object.title, + description: object.description, + table_data: object.table_data, + image: object.image }; }, }), diff --git a/app/page.tsx b/app/page.tsx index 4c7c405..779f5c6 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -52,6 +52,7 @@ import { import { cn } from '@/lib/utils'; import { Tweet } from 'react-tweet' import Image from 'next/image'; +import { TweetGrid } from '@/components/ui/tweet-grid'; function BentoCard({ title, @@ -98,59 +99,18 @@ const TestimonialSection: React.FC = () => { "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 (
-
+

What People Are Saying

-
- - {[...tweetIds, ...tweetIds].map((id, index) => ( -
- -
- ))} -
-
-
- {tweetIds.map((id) => ( -
- -
- ))} +
+
+
); diff --git a/app/search/page.tsx b/app/search/page.tsx index 1e5b28e..b1a6300 100644 --- a/app/search/page.tsx +++ b/app/search/page.tsx @@ -175,7 +175,7 @@ const HomeContent = () => { const [openChangelog, setOpenChangelog] = useState(false); const { isLoading, input, messages, setInput, handleInputChange, append, handleSubmit, setMessages, reload } = useChat({ - maxToolRoundtrips: 2, + maxToolRoundtrips: selectedModel === 'mistral:pixtral-12b-2409' ? 1 : 2, body: { model: selectedModel, }, @@ -1626,14 +1626,6 @@ The o1-mini is a new OpenAI model that is optimized for reasoning tasks. Current return metadata; }, [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 [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; return ( -
+
Favicon = { paragraph(children) { - return ( -

- {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 ( - - {part} - - ); - } else if (part.startsWith('$') && part.endsWith('$')) { - // Inline equation - return ( - - {part} - - ); - } // add $$ for display mode equations - else if (part.startsWith('$$') && part.endsWith('$$')) { - // Display mode equation - return ( - - {part} - - ); - } - // Regular text - return part; - }); - } - return child; - })} -

- ); + return

{children}

; }, code(children, language) { return {String(children)}; }, link(href, text) { + // if (!href) return <>{text}; + const citationIndex = citationLinks.findIndex(link => link.link === href); if (citationIndex !== -1) { 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 (
- {preprocessedContent} + {content}
); }; diff --git a/components/ui/tweet-grid.tsx b/components/ui/tweet-grid.tsx new file mode 100644 index 0000000..3c62c19 --- /dev/null +++ b/components/ui/tweet-grid.tsx @@ -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, + VariantProps { + tweets: string[] + className?: string +} + +export const TweetGrid: React.FC = ({ + tweets, + columns, + spacing, + className, +}) => { + return ( +
+ {tweets.map((tweetId, i) => ( +
+ +
+ ))} +
+ ) +}