-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
50 lines (44 loc) · 1.08 KB
/
index.ts
File metadata and controls
50 lines (44 loc) · 1.08 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { SearchService } from '../services/search-service.js';
import {
WebSearchArgs,
ToolResponse
} from '../types/index.js';
// Initialize service
const searchService = new SearchService({
apiKey: process.env.BRAVE_API_KEY || ''
});
export const tools = [
{
name: "web_search",
description: "Seach from web to get more information",
inputSchema: {
type: "object",
properties: {
query: {
type: "string",
description: "Give a clear search query for get clear response"
},
},
required: ["query"]
},
handler: async (args: WebSearchArgs): Promise<ToolResponse> => {
const result:any = await searchService.search(args.query);
if (!result.success) {
return {
content: [{
type: "text",
text: `Error searching: ${result.error}`,
status: 500
}]
};
}
return {
content: [{
type: "text",
text: JSON.stringify(result.data),
status: 200
}]
};
}
}
];