Add website fetch ai tool

This commit is contained in:
Aslan 2026-01-27 07:36:17 -05:00
parent 40cc798afa
commit 8fbb8f6a23
2 changed files with 39 additions and 2 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "aslobot-matrix", "name": "aslobot-matrix",
"version": "1.3.0", "version": "1.3.0-dev",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "aslobot-matrix", "name": "aslobot-matrix",
"version": "1.3.0", "version": "1.3.0-dev",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@google/genai": "^1.34.0", "@google/genai": "^1.34.0",

View file

@ -121,6 +121,20 @@ const tools: FunctionDeclaration[] = [
required: [], required: [],
}, },
}, },
{
name: "readWebsite",
description: "Returns a html of a website for AI analysis",
parametersJsonSchema: {
type: "object",
properties: {
url: {
type: "string",
description: "a full url of the website to fetch",
},
},
required: ["url"],
},
},
{ {
name: "generateImage", name: "generateImage",
description: "Generates an image or a picture based on the prompt", description: "Generates an image or a picture based on the prompt",
@ -295,6 +309,29 @@ const toolFunctions: AIToolFunction[] = [
}; };
}, },
}, },
{
name: "readWebsite",
function: async (matrix, args) => {
if (!args.url) {
return {
message: "url is required",
};
}
matrix.client.sendTextMessage(
matrix.roomId,
`Downloading ${args.url}...`,
);
const response = await fetch(args.url);
const contents = await response.text();
return {
message: "website fetched",
html: contents,
};
},
},
{ {
name: "generateImage", name: "generateImage",
function: (matrix, args) => { function: (matrix, args) => {