Add website fetch ai tool
This commit is contained in:
parent
40cc798afa
commit
8fbb8f6a23
2 changed files with 39 additions and 2 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "aslobot-matrix",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.0-dev",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "aslobot-matrix",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.0-dev",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@google/genai": "^1.34.0",
|
||||
|
|
|
|||
|
|
@ -121,6 +121,20 @@ const tools: FunctionDeclaration[] = [
|
|||
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",
|
||||
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",
|
||||
function: (matrix, args) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue