fixes and wip

This commit is contained in:
zaidmukaddam 2024-11-06 00:48:42 +05:30
parent 065bbe7887
commit d7005917ff
4 changed files with 21 additions and 21 deletions

View File

@ -14,7 +14,7 @@ export async function suggestQuestions(history: any[]) {
'use server'; 'use server';
const { object } = await generateObject({ const { object } = await generateObject({
model: groq('llama-3.2-11b-text-preview'), model: groq('llama-3.2-90b-text-preview'),
temperature: 0, temperature: 0,
system: 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. `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.

View File

@ -12,7 +12,7 @@ import CodeInterpreter from "@e2b/code-interpreter";
import FirecrawlApp from '@mendable/firecrawl-js'; import FirecrawlApp from '@mendable/firecrawl-js';
// Allow streaming responses up to 60 seconds // Allow streaming responses up to 60 seconds
export const maxDuration = 120; export const maxDuration = 60;
// Azure setup // Azure setup
const azure = createAzure({ const azure = createAzure({
@ -54,10 +54,9 @@ export async function POST(req: Request) {
const provider = model.split(":")[0]; const provider = model.split(":")[0];
const result = await streamText({ const result = await streamText({
maxSteps: 10,
model: registry.languageModel(model), model: registry.languageModel(model),
messages: convertToCoreMessages(messages), messages: messages,
temperature: provider === "azure" ? 0.72 : 0, temperature: provider === "azure" ? 0.72 : 0.2,
topP: 0.5, topP: 0.5,
frequencyPenalty: 0, frequencyPenalty: 0,
presencePenalty: 0, presencePenalty: 0,
@ -176,12 +175,6 @@ 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,
@ -189,17 +182,21 @@ 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
// 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({ let body = JSON.stringify({
api_key: apiKey, api_key: apiKey,
@ -276,8 +273,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
}; };
}, },
}), }),
@ -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.", description: "Write and execute Python code.",
parameters: z.object({ parameters: z.object({
title: z.string().describe("The title of the code snippet."), 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."), 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 sandbox = await CodeInterpreter.create();
const execution = await sandbox.runCode(code); const execution = await sandbox.runCode(code);
let message = ""; 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("Error: ", execution.error);
} }
console.log(execution.results[0].chart) console.log(execution.results)
if (execution.results[0].chart) { if (execution.results[0].chart) {
execution.results[0].chart.elements.map((element: any) => { execution.results[0].chart.elements.map((element: any) => {
console.log(element.points) console.log(element.points)

View File

@ -149,7 +149,7 @@ const HomeContent = () => {
const [openChangelog, setOpenChangelog] = useState(false); const [openChangelog, setOpenChangelog] = useState(false);
const { isLoading, input, messages, setInput, handleInputChange, append, handleSubmit, setMessages, reload, stop } = useChat({ const { isLoading, input, messages, setInput, handleInputChange, append, handleSubmit, setMessages, reload, stop } = useChat({
maxToolRoundtrips: selectedModel === 'mistral:pixtral-12b-2409' ? 1 : 2, maxSteps: 10,
body: { body: {
model: selectedModel, model: selectedModel,
}, },
@ -162,7 +162,7 @@ const HomeContent = () => {
} }
}, },
onError: (error) => { onError: (error) => {
console.error("Chat error:", error); console.error("Chat error:", error.cause, error.message);
toast.error("An error occurred.", { toast.error("An error occurred.", {
description: "We must have ran out of credits. Sponsor us on GitHub to keep this service running.", description: "We must have ran out of credits. Sponsor us on GitHub to keep this service running.",
action: { action: {

View File

@ -209,7 +209,7 @@ const InteractiveChart: React.FC<ChartProps> = ({
<CardContent> <CardContent>
<ReactECharts <ReactECharts
option={options} option={options}
style={{ height: '400px', width: '100%' }} style={{ height: '460px', width: '105%', gap: '20px' }}
/> />
</CardContent> </CardContent>
</Card> </Card>