Project Files
src / tools / tools.ts
import { tool } from "@lmstudio/sdk";
import { z } from "zod";
import { crawlPage } from "./crawlPage";
export const toolsProvider = {
searchWeb: tool({
description: "Crawls a website to retrieve content to answer queries.",
parameters: z.object({
url: z.string().describe("The URL to crawl"),
query: z.string().optional().describe("Optional search query for relevance"),
}),
execute: async ({ url, query }) => {
try {
const result = await crawlPage(url, query || "");
return {
title: result.title,
content: result.content, // Ensure this returns the cleaned string
};
} catch (error) {
return { error: String(error) };
}
},
}),
};