triangle-utils 1.4.102 → 1.4.103
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.d.ts +3 -0
- package/dist/src/UtilsBedrock.js +31 -0
- package/dist/src/f.js +5 -3
- package/package.json +1 -1
- package/src/UtilsBedrock.ts +31 -0
- package/src/f.ts +8 -4
|
@@ -35,5 +35,8 @@ export declare class UtilsBedrock {
|
|
|
35
35
|
llama_invoke(model_id: string, prompt: string, temperature?: number, max_gen_len?: number, top_p?: number): Promise<string | undefined>;
|
|
36
36
|
gpt_converse(model_id: string, prompt: string, temperature?: number, max_gen_len?: number, top_p?: number): Promise<string | undefined>;
|
|
37
37
|
titan_invoke(text: string): Promise<number[] | undefined>;
|
|
38
|
+
cohere_invoke(model_id: string, text: string, options?: {
|
|
39
|
+
input_type_id?: string;
|
|
40
|
+
}): Promise<number[] | undefined>;
|
|
38
41
|
}
|
|
39
42
|
export {};
|
package/dist/src/UtilsBedrock.js
CHANGED
|
@@ -272,4 +272,35 @@ export class UtilsBedrock {
|
|
|
272
272
|
console.log("Failed to get from Bedrock, quitting.");
|
|
273
273
|
return undefined;
|
|
274
274
|
}
|
|
275
|
+
async cohere_invoke(model_id, text, options = {}) {
|
|
276
|
+
try {
|
|
277
|
+
const output = await this.bedrock_runtime.invokeModel({
|
|
278
|
+
modelId: model_id,
|
|
279
|
+
body: JSON.stringify({
|
|
280
|
+
input_type: options.input_type_id || "search_document",
|
|
281
|
+
inputs: [
|
|
282
|
+
{
|
|
283
|
+
content: [
|
|
284
|
+
{ type: "text", text: text }
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
],
|
|
288
|
+
output_dimension: 1024,
|
|
289
|
+
truncate: "RIGHT",
|
|
290
|
+
max_tokens: 128000
|
|
291
|
+
}),
|
|
292
|
+
contentType: "application/json"
|
|
293
|
+
});
|
|
294
|
+
const response = JSON.parse(this.text_decoder.decode(output.body));
|
|
295
|
+
const coordinates = response.embeddings.float[0];
|
|
296
|
+
if (coordinates !== undefined && Array.isArray(coordinates) && coordinates.every((i) => typeof i === "number")) {
|
|
297
|
+
return coordinates;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
console.log(error.stack);
|
|
302
|
+
console.log("Failed to get from Bedrock.");
|
|
303
|
+
}
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
275
306
|
}
|
package/dist/src/f.js
CHANGED
|
@@ -15,9 +15,9 @@ const config = {
|
|
|
15
15
|
};
|
|
16
16
|
console.log(config);
|
|
17
17
|
const utils = new TriangleUtils(config);
|
|
18
|
-
const raw_s3_id_prefix = config.s3_scout + "/raw_scout_documents/57523929653b604e/"
|
|
19
|
-
const raw_s3_ids = await utils.s3.query_prefix(raw_s3_id_prefix, { compile: true })
|
|
20
|
-
console.log(raw_s3_ids)
|
|
18
|
+
// const raw_s3_id_prefix = config.s3_scout + "/raw_scout_documents/57523929653b604e/"
|
|
19
|
+
// const raw_s3_ids = await utils.s3.query_prefix(raw_s3_id_prefix, { compile : true })
|
|
20
|
+
// console.log(raw_s3_ids)
|
|
21
21
|
// const text = await utils.xai.grok_simple_query("grok-4.3", "Find the X username corresponding to the candidate of the committee \"Darializa for Congress\"", {
|
|
22
22
|
// print_usage : true,
|
|
23
23
|
// json_format : {
|
|
@@ -232,3 +232,5 @@ console.log(raw_s3_ids);
|
|
|
232
232
|
// }
|
|
233
233
|
// )
|
|
234
234
|
// console.log(response)
|
|
235
|
+
const coordinates = await utils.bedrock.cohere_invoke("global.cohere.embed-v4:0", "yerrp");
|
|
236
|
+
console.log(coordinates);
|
package/package.json
CHANGED
package/src/UtilsBedrock.ts
CHANGED
|
@@ -308,4 +308,35 @@ export class UtilsBedrock {
|
|
|
308
308
|
return undefined
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
async cohere_invoke(model_id : string, text : string, options : { input_type_id? : string } = {}) : Promise<number[] | undefined> {
|
|
312
|
+
try {
|
|
313
|
+
const output = await this.bedrock_runtime.invokeModel({
|
|
314
|
+
modelId : model_id,
|
|
315
|
+
body : JSON.stringify({
|
|
316
|
+
input_type: options.input_type_id || "search_document",
|
|
317
|
+
inputs: [
|
|
318
|
+
{
|
|
319
|
+
content: [
|
|
320
|
+
{ type : "text", text : text }
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
output_dimension: 1024,
|
|
325
|
+
truncate: "RIGHT",
|
|
326
|
+
max_tokens: 128000
|
|
327
|
+
}),
|
|
328
|
+
contentType : "application/json"
|
|
329
|
+
})
|
|
330
|
+
const response = JSON.parse(this.text_decoder.decode(output.body))
|
|
331
|
+
const coordinates = response.embeddings.float[0]
|
|
332
|
+
if (coordinates !== undefined && Array.isArray(coordinates) && coordinates.every((i : any) => typeof i === "number")) {
|
|
333
|
+
return coordinates
|
|
334
|
+
}
|
|
335
|
+
} catch (error : any) {
|
|
336
|
+
console.log(error.stack)
|
|
337
|
+
console.log("Failed to get from Bedrock.")
|
|
338
|
+
}
|
|
339
|
+
return undefined
|
|
340
|
+
}
|
|
341
|
+
|
|
311
342
|
}
|
package/src/f.ts
CHANGED
|
@@ -24,10 +24,10 @@ console.log(config)
|
|
|
24
24
|
|
|
25
25
|
const utils = new TriangleUtils(config)
|
|
26
26
|
|
|
27
|
-
const raw_s3_id_prefix = config.s3_scout + "/raw_scout_documents/57523929653b604e/"
|
|
28
|
-
const raw_s3_ids = await utils.s3.query_prefix(raw_s3_id_prefix, { compile : true })
|
|
27
|
+
// const raw_s3_id_prefix = config.s3_scout + "/raw_scout_documents/57523929653b604e/"
|
|
28
|
+
// const raw_s3_ids = await utils.s3.query_prefix(raw_s3_id_prefix, { compile : true })
|
|
29
29
|
|
|
30
|
-
console.log(raw_s3_ids)
|
|
30
|
+
// console.log(raw_s3_ids)
|
|
31
31
|
|
|
32
32
|
// const text = await utils.xai.grok_simple_query("grok-4.3", "Find the X username corresponding to the candidate of the committee \"Darializa for Congress\"", {
|
|
33
33
|
// print_usage : true,
|
|
@@ -268,4 +268,8 @@ console.log(raw_s3_ids)
|
|
|
268
268
|
// print_usage : true
|
|
269
269
|
// }
|
|
270
270
|
// )
|
|
271
|
-
// console.log(response)
|
|
271
|
+
// console.log(response)
|
|
272
|
+
|
|
273
|
+
const coordinates = await utils.bedrock.cohere_invoke("global.cohere.embed-v4:0", "yerrp")
|
|
274
|
+
|
|
275
|
+
console.log(coordinates)
|