From d7005917ffa7e5d86248ba0f402e4a928cf19b89 Mon Sep 17 00:00:00 2001 From: zaidmukaddam Date: Wed, 6 Nov 2024 00:48:42 +0530 Subject: [PATCH] fixes and wip --- app/actions.ts | 2 +- app/api/chat/route.ts | 34 +++++++++++++++---------------- app/search/page.tsx | 4 ++-- components/interactive-charts.tsx | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/actions.ts b/app/actions.ts index ca7387d..ecb8cf7 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -14,7 +14,7 @@ export async function suggestQuestions(history: any[]) { 'use server'; const { object } = await generateObject({ - model: groq('llama-3.2-11b-text-preview'), + model: groq('llama-3.2-90b-text-preview'), temperature: 0, system: `You are a search engine query generator. You 'have' to create only '3' questions for the search engine based on the message history which has been provided to you. diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 1407180..c29e915 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -12,7 +12,7 @@ import CodeInterpreter from "@e2b/code-interpreter"; import FirecrawlApp from '@mendable/firecrawl-js'; // Allow streaming responses up to 60 seconds -export const maxDuration = 120; +export const maxDuration = 60; // Azure setup const azure = createAzure({ @@ -54,10 +54,9 @@ export async function POST(req: Request) { const provider = model.split(":")[0]; const result = await streamText({ - maxSteps: 10, model: registry.languageModel(model), - messages: convertToCoreMessages(messages), - temperature: provider === "azure" ? 0.72 : 0, + messages: messages, + temperature: provider === "azure" ? 0.72 : 0.2, topP: 0.5, frequencyPenalty: 0, presencePenalty: 0, @@ -176,12 +175,6 @@ 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, @@ -189,17 +182,21 @@ 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 + // log all the parameters + console.log("Query:", query); + console.log("Max Results:", maxResults); + console.log("Topic:", topic); + console.log("Search Depth:", searchDepth); + console.log("Exclude Domains:", exclude_domains); let body = JSON.stringify({ api_key: apiKey, @@ -276,8 +273,7 @@ When asked a "What is" question, maintain the same format as the question and an return { results: context, - images: processedImages, - need_overview + images: processedImages }; }, }), @@ -371,10 +367,14 @@ When asked a "What is" question, maintain the same format as the question and an description: "Write and execute Python code.", parameters: z.object({ title: z.string().describe("The title of the code snippet."), - code: z.string().describe("The Python code to execute."), + code: z.string().describe("The Python code to execute. put the variables in the end of the code to print them. do not use the print function."), icon: z.enum(["stock", "date", "calculation", "default"]).describe("The icon to display for the code snippet."), }), - execute: async ({ code }: { code: string }) => { + execute: async ({ code, title, icon }: { code: string, title: string, icon: string }) => { + console.log("Code:", code); + console.log("Title:", title); + console.log("Icon:", icon); + const sandbox = await CodeInterpreter.create(); const execution = await sandbox.runCode(code); let message = ""; @@ -440,7 +440,7 @@ When asked a "What is" question, maintain the same format as the question and an console.log("Error: ", execution.error); } - console.log(execution.results[0].chart) + console.log(execution.results) if (execution.results[0].chart) { execution.results[0].chart.elements.map((element: any) => { console.log(element.points) diff --git a/app/search/page.tsx b/app/search/page.tsx index 82a0d6e..b3a1445 100644 --- a/app/search/page.tsx +++ b/app/search/page.tsx @@ -149,7 +149,7 @@ const HomeContent = () => { const [openChangelog, setOpenChangelog] = useState(false); const { isLoading, input, messages, setInput, handleInputChange, append, handleSubmit, setMessages, reload, stop } = useChat({ - maxToolRoundtrips: selectedModel === 'mistral:pixtral-12b-2409' ? 1 : 2, + maxSteps: 10, body: { model: selectedModel, }, @@ -162,7 +162,7 @@ const HomeContent = () => { } }, onError: (error) => { - console.error("Chat error:", error); + console.error("Chat error:", error.cause, error.message); toast.error("An error occurred.", { description: "We must have ran out of credits. Sponsor us on GitHub to keep this service running.", action: { diff --git a/components/interactive-charts.tsx b/components/interactive-charts.tsx index 6d74910..9c17f36 100644 --- a/components/interactive-charts.tsx +++ b/components/interactive-charts.tsx @@ -209,7 +209,7 @@ const InteractiveChart: React.FC = ({