diff --git a/.continue/prompts/update-llm-info.prompt b/.continue/prompts/update-llm-info.prompt index 7264ebf38..9c1cf1f8e 100644 --- a/.continue/prompts/update-llm-info.prompt +++ b/.continue/prompts/update-llm-info.prompt @@ -44,8 +44,8 @@ export const AllMediaTypes = [ 2. EXTRACT NEW INFORMATION -New information will be pulled from the internet. -If you do not see a web search tool, let me know. +Fetch information from the internet using the search web and read url tools. +If you do not see either of these tools, stop and let me know. Retrieve the following sites per these providers, and consider these notes on how to extract the information: - "gemini": https://ai.google.dev/gemini-api/docs/models - maxCompletionTokens is called "Output token limit", contextLength is called "Input token limit" diff --git a/core/tools/builtIn.ts b/core/tools/builtIn.ts index 892cc3ff8..5a2408a0c 100644 --- a/core/tools/builtIn.ts +++ b/core/tools/builtIn.ts @@ -11,6 +11,7 @@ export enum BuiltInToolNames { LSTool = "builtin_ls", CreateRuleBlock = "builtin_create_rule_block", RequestRule = "builtin_request_rule", + FetchUrlContent = "builtin_fetch_url_content", // excluded from allTools for now ViewRepoMap = "builtin_view_repo_map", diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 6ea95610b..40dd7abe2 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -5,6 +5,7 @@ import { BuiltInToolNames } from "./builtIn"; import { createNewFileImpl } from "./implementations/createNewFile"; import { createRuleBlockImpl } from "./implementations/createRuleBlock"; +import { fetchUrlContentImpl } from "./implementations/fetchUrlContent"; import { fileGlobSearchImpl } from "./implementations/globSearch"; import { grepSearchImpl } from "./implementations/grepSearch"; import { lsToolImpl } from "./implementations/lsTool"; @@ -151,6 +152,8 @@ async function callBuiltInTool( return await runTerminalCommandImpl(args, extras); case BuiltInToolNames.SearchWeb: return await searchWebImpl(args, extras); + case BuiltInToolNames.FetchUrlContent: + return await fetchUrlContentImpl(args, extras); case BuiltInToolNames.ViewDiff: return await viewDiffImpl(args, extras); case BuiltInToolNames.LSTool: diff --git a/core/tools/definitions/editFile.ts b/core/tools/definitions/editFile.ts index 1653cb279..6c6ad6fd9 100644 --- a/core/tools/definitions/editFile.ts +++ b/core/tools/definitions/editFile.ts @@ -14,6 +14,7 @@ export const editFileTool: Tool = { hasAlready: "edited {{{ filepath }}}", group: BUILT_IN_GROUP_NAME, readonly: false, + isInstant: false, function: { name: BuiltInToolNames.EditExistingFile, description: diff --git a/core/tools/definitions/fetchUrlContent.ts b/core/tools/definitions/fetchUrlContent.ts new file mode 100644 index 000000000..e0122f55b --- /dev/null +++ b/core/tools/definitions/fetchUrlContent.ts @@ -0,0 +1,28 @@ +import { Tool } from "../.."; +import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; + +export const fetchUrlContentTool: Tool = { + type: "function", + displayTitle: "Read URL", + wouldLikeTo: "fetch {{{ url }}}", + isCurrently: "fetching {{{ url }}}", + hasAlready: "viewed {{{ url }}}", + readonly: true, + isInstant: true, + group: BUILT_IN_GROUP_NAME, + function: { + name: BuiltInToolNames.FetchUrlContent, + description: + "Can be used to view the contents of a website using a URL. Do NOT use this for files.", + parameters: { + type: "object", + required: ["url"], + properties: { + url: { + type: "string", + description: "The URL to read", + }, + }, + }, + }, +}; diff --git a/core/tools/implementations/fetchUrlContent.ts b/core/tools/implementations/fetchUrlContent.ts new file mode 100644 index 000000000..d2c031d4e --- /dev/null +++ b/core/tools/implementations/fetchUrlContent.ts @@ -0,0 +1,6 @@ +import { ToolImpl } from "."; +import { getUrlContextItems } from "../../context/providers/URLContextProvider"; + +export const fetchUrlContentImpl: ToolImpl = async (args, extras) => { + return getUrlContextItems(args.url, extras.fetch); +}; diff --git a/core/tools/index.ts b/core/tools/index.ts index f7ed3be4b..c4d1c658b 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -2,6 +2,7 @@ import { ConfigDependentToolParams, Tool } from ".."; import { createNewFileTool } from "./definitions/createNewFile"; import { createRuleBlock } from "./definitions/createRuleBlock"; import { editFileTool } from "./definitions/editFile"; +import { fetchUrlContentTool } from "./definitions/fetchUrlContent"; import { globSearchTool } from "./definitions/globSearch"; import { grepSearchTool } from "./definitions/grepSearch"; import { lsTool } from "./definitions/lsTool"; @@ -24,6 +25,7 @@ export const baseToolDefinitions = [ readCurrentlyOpenFileTool, lsTool, createRuleBlock, + fetchUrlContentTool, // replacing with ls tool for now // viewSubdirectoryTool, // viewRepoMapTool, diff --git a/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx b/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx index 7c67463a9..3c7ce9390 100644 --- a/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx @@ -33,27 +33,21 @@ export function ContextItemsPeekItem({ function openContextItem() { const { uri, name, content } = contextItem; - if (isUrl) { - if (uri?.value) { - ideMessenger.post("openUrl", uri.value); - } else { - console.error("Couldn't open url", uri); - } - } else if (uri) { + if (uri && uri?.type === "file") { const isRangeInFile = name.includes(" (") && name.endsWith(")"); if (isRangeInFile) { const rif = ctxItemToRifWithContents(contextItem, true); - ideMessenger.ide.showLines( + void ideMessenger.ide.showLines( rif.filepath, rif.range.start.line, rif.range.end.line, ); } else { - ideMessenger.ide.openFile(uri.value); + void ideMessenger.ide.openFile(uri.value); } } else { - ideMessenger.ide.showVirtualFile(name, content); + void ideMessenger.ide.showVirtualFile(name, content); } } @@ -136,6 +130,18 @@ export function ContextItemsPeekItem({