triangle-utils 1.4.111 → 1.4.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/UtilsBedrock.js +1 -1
- package/dist/src/UtilsBee.d.ts +3 -1
- package/dist/src/UtilsBee.js +25 -28
- package/package.json +1 -1
- package/src/UtilsBedrock.ts +1 -1
- package/src/UtilsBee.ts +26 -29
package/dist/src/UtilsBedrock.js
CHANGED
|
@@ -45,7 +45,7 @@ export class UtilsBedrock {
|
|
|
45
45
|
model: model_id,
|
|
46
46
|
messages: message_params,
|
|
47
47
|
system: options.system_prompt,
|
|
48
|
-
tools: options.web === true ? [{ name: "web_search", type: "
|
|
48
|
+
tools: options.web === true ? [{ name: "web_search", type: "web_search_20260318" }] : [],
|
|
49
49
|
max_tokens: options.max_tokens || 1000,
|
|
50
50
|
output_config: options.json_format !== undefined ? {
|
|
51
51
|
format: {
|
package/dist/src/UtilsBee.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ export declare class UtilsBee {
|
|
|
4
4
|
constructor(scraping_bee_api_key: string | undefined);
|
|
5
5
|
get_buffer(url: string, params?: Record<string, string | number | boolean>): Promise<Error | Buffer<any> | undefined>;
|
|
6
6
|
get(url: string, params?: Record<string, string | number | boolean>): Promise<string | Error | undefined>;
|
|
7
|
-
google_search(query: string,
|
|
7
|
+
google_search(query: string, options?: {
|
|
8
|
+
search_type_id?: string;
|
|
9
|
+
}): Promise<Record<string, any>[] | undefined>;
|
|
8
10
|
youtube_search(query: string, options?: {}): Promise<Record<string, any>[] | undefined>;
|
|
9
11
|
youtube_get_subtitles(video_id: string): Promise<Record<string, any> | undefined>;
|
|
10
12
|
}
|
package/dist/src/UtilsBee.js
CHANGED
|
@@ -39,42 +39,39 @@ export class UtilsBee {
|
|
|
39
39
|
}
|
|
40
40
|
return this.text_decoder.decode(buffer);
|
|
41
41
|
}
|
|
42
|
-
async google_search(query,
|
|
42
|
+
async google_search(query, options = {}) {
|
|
43
43
|
if (this.bee === undefined) {
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
search_type: news ? "news" : undefined
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
if (response.status !== 200) {
|
|
55
|
-
console.log("Failed to Google:", response.status);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
const data = JSON.parse(response.data.toString("utf-8"));
|
|
59
|
-
if (data.news_results === undefined || data.organic_results === undefined) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const results = news ? data.news_results : data.organic_results;
|
|
63
|
-
if (results === undefined) {
|
|
64
|
-
console.log("Failed to Google.");
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (!Array.isArray(results)) {
|
|
68
|
-
console.log("Results are not an array.");
|
|
69
|
-
return;
|
|
46
|
+
try {
|
|
47
|
+
const response = await this.bee.googleSearch({
|
|
48
|
+
search: query,
|
|
49
|
+
params: {
|
|
50
|
+
search_type: options.search_type_id
|
|
70
51
|
}
|
|
71
|
-
|
|
52
|
+
});
|
|
53
|
+
if (response.status !== 200) {
|
|
54
|
+
console.log("Failed to Google:", response.status);
|
|
55
|
+
return;
|
|
72
56
|
}
|
|
73
|
-
|
|
57
|
+
const data = JSON.parse(response.data.toString("utf-8"));
|
|
58
|
+
if (data.news_results === undefined || data.organic_results === undefined) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const results = options.search_type_id === "news" ? data.news_results : data.organic_results;
|
|
62
|
+
if (results === undefined) {
|
|
74
63
|
console.log("Failed to Google.");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!Array.isArray(results)) {
|
|
67
|
+
console.log("Results are not an array.");
|
|
68
|
+
return;
|
|
75
69
|
}
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.log("Failed to Google:", error.stack);
|
|
76
74
|
}
|
|
77
|
-
console.log("Failed to Google thrice, quitting.");
|
|
78
75
|
return undefined;
|
|
79
76
|
}
|
|
80
77
|
async youtube_search(query, options = {}) {
|
package/package.json
CHANGED
package/src/UtilsBedrock.ts
CHANGED
|
@@ -68,7 +68,7 @@ export class UtilsBedrock {
|
|
|
68
68
|
model : model_id,
|
|
69
69
|
messages : message_params,
|
|
70
70
|
system : options.system_prompt,
|
|
71
|
-
tools : options.web === true ? [{ name : "web_search", type : "
|
|
71
|
+
tools : options.web === true ? [{ name : "web_search", type : "web_search_20260318" }] : [],
|
|
72
72
|
max_tokens : options.max_tokens || 1000,
|
|
73
73
|
output_config : options.json_format !== undefined ? {
|
|
74
74
|
format : {
|
package/src/UtilsBee.ts
CHANGED
|
@@ -45,44 +45,41 @@ export class UtilsBee {
|
|
|
45
45
|
return this.text_decoder.decode(buffer)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
async google_search(query : string,
|
|
48
|
+
async google_search(query : string, options : { search_type_id? : string } = {}) : Promise<Record<string, any>[] | undefined> {
|
|
49
49
|
if (this.bee === undefined) {
|
|
50
50
|
return undefined
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
search_type : news ? "news" : undefined
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
if (response.status !== 200) {
|
|
61
|
-
console.log("Failed to Google:", response.status)
|
|
62
|
-
continue
|
|
63
|
-
}
|
|
64
|
-
const data : Record<string, any> = JSON.parse(response.data.toString("utf-8"))
|
|
65
|
-
|
|
66
|
-
if (data.news_results === undefined || data.organic_results === undefined) {
|
|
67
|
-
continue
|
|
52
|
+
try {
|
|
53
|
+
const response = await this.bee.googleSearch({
|
|
54
|
+
search : query,
|
|
55
|
+
params : {
|
|
56
|
+
search_type : options.search_type_id
|
|
68
57
|
}
|
|
69
|
-
|
|
58
|
+
})
|
|
59
|
+
if (response.status !== 200) {
|
|
60
|
+
console.log("Failed to Google:", response.status)
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
const data : Record<string, any> = JSON.parse(response.data.toString("utf-8"))
|
|
64
|
+
|
|
65
|
+
if (data.news_results === undefined || data.organic_results === undefined) {
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
const results : Record<string, any>[] | undefined = options.search_type_id === "news" ? data.news_results : data.organic_results
|
|
70
69
|
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
console.log("Failed to Google.")
|
|
74
|
-
continue
|
|
75
|
-
}
|
|
76
|
-
if (!Array.isArray(results)) {
|
|
77
|
-
console.log("Results are not an array.")
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
return results
|
|
81
|
-
} catch {
|
|
71
|
+
if (results === undefined) {
|
|
82
72
|
console.log("Failed to Google.")
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
if (!Array.isArray(results)) {
|
|
76
|
+
console.log("Results are not an array.")
|
|
77
|
+
return
|
|
83
78
|
}
|
|
79
|
+
return results
|
|
80
|
+
} catch (error : any) {
|
|
81
|
+
console.log("Failed to Google:", error.stack)
|
|
84
82
|
}
|
|
85
|
-
console.log("Failed to Google thrice, quitting.")
|
|
86
83
|
return undefined
|
|
87
84
|
}
|
|
88
85
|
|