-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.js
More file actions
30 lines (25 loc) · 755 Bytes
/
utils.js
File metadata and controls
30 lines (25 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const { http_request } = require('node:process');
async function web_search_tool(query) {
try {
const url = `https://zeroclaw.com/api/tool/web_search_tool`;
const body = JSON.stringify({query});
const headers = {
'Content-Type': 'application/json',
};
const response = await http_request(url, {
method: 'POST',
headers,
body,
});
if (!response.ok) {
console.error(`HTTP error! status: ${response.status}`);
return { error: `HTTP error! status: ${response.status}` };
}
const data = await response.json();
return data;
} catch (error) {
console.error('Error during web search:', error);
return { error: error.message };
}
}
module.exports = { web_search_tool };