triangle-utils 1.4.64 → 1.4.66
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/UtilsAnthropic.d.ts +2 -0
- package/dist/src/UtilsAnthropic.js +2 -0
- package/dist/src/UtilsTwitter.d.ts +6 -0
- package/dist/src/UtilsTwitter.js +75 -0
- package/dist/src/f.js +113 -20
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +4 -4
- package/package.json +2 -1
- package/src/UtilsAnthropic.ts +6 -2
- package/src/UtilsTwitter.ts +80 -0
- package/src/f.ts +124 -20
- package/src/index.ts +4 -4
|
@@ -5,10 +5,12 @@ export declare class UtilsAnthropic {
|
|
|
5
5
|
max_tokens?: number;
|
|
6
6
|
print_usage?: boolean;
|
|
7
7
|
json_format?: Record<string, any>;
|
|
8
|
+
web?: boolean;
|
|
8
9
|
}): Promise<string | undefined>;
|
|
9
10
|
claude_query(model_id: string, prompt: string, attachment_pdf?: string, options?: {
|
|
10
11
|
max_tokens?: number;
|
|
11
12
|
print_usage?: boolean;
|
|
12
13
|
json_format?: Record<string, any>;
|
|
14
|
+
web?: boolean;
|
|
13
15
|
}): Promise<string | undefined>;
|
|
14
16
|
}
|
|
@@ -17,6 +17,7 @@ export class UtilsAnthropic {
|
|
|
17
17
|
}
|
|
18
18
|
]
|
|
19
19
|
})),
|
|
20
|
+
tools: options.web === true ? [{ name: "web_search", type: "web_search_20260209" }] : [],
|
|
20
21
|
max_tokens: options.max_tokens || 1000,
|
|
21
22
|
output_config: options.json_format !== undefined ? {
|
|
22
23
|
format: {
|
|
@@ -68,6 +69,7 @@ export class UtilsAnthropic {
|
|
|
68
69
|
role: "user",
|
|
69
70
|
content: message_contents
|
|
70
71
|
}],
|
|
72
|
+
tools: options.web === true ? [{ name: "web_search", type: "web_search_20260209" }] : [],
|
|
71
73
|
max_tokens: options.max_tokens || 1000,
|
|
72
74
|
output_config: options.json_format !== undefined ? {
|
|
73
75
|
format: {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Client } from "@xdevplatform/xdk";
|
|
2
|
+
export class UtilsTwitter {
|
|
3
|
+
twitter;
|
|
4
|
+
constructor(twitter_api_key) {
|
|
5
|
+
this.twitter = new Client({ bearerToken: twitter_api_key });
|
|
6
|
+
}
|
|
7
|
+
async get_user_by_username(username) {
|
|
8
|
+
const result = await this.twitter.users.getByUsername(username, { userFields: [
|
|
9
|
+
"affiliation",
|
|
10
|
+
// "confirmed_email",
|
|
11
|
+
"connection_status",
|
|
12
|
+
"created_at",
|
|
13
|
+
"description",
|
|
14
|
+
"entities",
|
|
15
|
+
"id",
|
|
16
|
+
"is_identity_verified",
|
|
17
|
+
"location",
|
|
18
|
+
"most_recent_tweet_id",
|
|
19
|
+
"name",
|
|
20
|
+
"parody",
|
|
21
|
+
"pinned_tweet_id",
|
|
22
|
+
"profile_banner_url",
|
|
23
|
+
"profile_image_url",
|
|
24
|
+
"protected",
|
|
25
|
+
// "public_metrics",
|
|
26
|
+
// "receives_your_dm",
|
|
27
|
+
"subscription",
|
|
28
|
+
"subscription_type",
|
|
29
|
+
"url",
|
|
30
|
+
"username",
|
|
31
|
+
"verified",
|
|
32
|
+
"verified_followers_count",
|
|
33
|
+
"verified_type",
|
|
34
|
+
"withheld"
|
|
35
|
+
] })
|
|
36
|
+
.then(response => response.data);
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
async get_tweets(user_id) {
|
|
40
|
+
const tweets = await this.twitter.users.getPosts(user_id, { tweetFields: [
|
|
41
|
+
"article",
|
|
42
|
+
"attachments",
|
|
43
|
+
"author_id",
|
|
44
|
+
"card_uri",
|
|
45
|
+
"community_id",
|
|
46
|
+
"context_annotations",
|
|
47
|
+
"conversation_id",
|
|
48
|
+
"created_at",
|
|
49
|
+
"display_text_range",
|
|
50
|
+
"edit_controls",
|
|
51
|
+
"edit_history_tweet_ids",
|
|
52
|
+
"entities",
|
|
53
|
+
"geo",
|
|
54
|
+
"id",
|
|
55
|
+
"in_reply_to_user_id",
|
|
56
|
+
"lang",
|
|
57
|
+
"matched_media_notes",
|
|
58
|
+
"media_metadata",
|
|
59
|
+
"note_request_suggestions",
|
|
60
|
+
"note_tweet",
|
|
61
|
+
"paid_partnership",
|
|
62
|
+
"possibly_sensitive",
|
|
63
|
+
"referenced_tweets",
|
|
64
|
+
"reply_settings",
|
|
65
|
+
"scopes",
|
|
66
|
+
"source",
|
|
67
|
+
"suggested_source_links",
|
|
68
|
+
"suggested_source_links_with_counts",
|
|
69
|
+
"text",
|
|
70
|
+
"withheld"
|
|
71
|
+
] })
|
|
72
|
+
.then(response => response.data);
|
|
73
|
+
return tweets;
|
|
74
|
+
}
|
|
75
|
+
}
|
package/dist/src/f.js
CHANGED
|
@@ -1,26 +1,119 @@
|
|
|
1
|
-
import { SecretsManager } from "@aws-sdk/client-secrets-manager"
|
|
2
|
-
import { TriangleUtils } from "./index.js"
|
|
3
|
-
console.log("Starting triangle-utils!")
|
|
4
|
-
const secret_name = "triage_config"
|
|
5
|
-
const secrets_manager = new SecretsManager({ region: "us-east-1" })
|
|
6
|
-
const response = await secrets_manager.getSecretValue({
|
|
7
|
-
|
|
8
|
-
})
|
|
9
|
-
const api_keys = JSON.parse(response?.SecretString || "")
|
|
10
|
-
const config = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
console.log(config)
|
|
17
|
-
const utils = new TriangleUtils(config)
|
|
1
|
+
// import { SecretsManager } from "@aws-sdk/client-secrets-manager"
|
|
2
|
+
// import { TriangleUtils } from "./index.js"
|
|
3
|
+
// console.log("Starting triangle-utils!")
|
|
4
|
+
// const secret_name = "triage_config"
|
|
5
|
+
// const secrets_manager = new SecretsManager({ region: "us-east-1" })
|
|
6
|
+
// const response = await secrets_manager.getSecretValue({
|
|
7
|
+
// SecretId: secret_name
|
|
8
|
+
// })
|
|
9
|
+
// const api_keys = JSON.parse(response?.SecretString || "")
|
|
10
|
+
// const config = {
|
|
11
|
+
// google_email : "louishou@triangleanalytics.com",
|
|
12
|
+
// alerts_email : "alerts@triangleanalytics.com",
|
|
13
|
+
// region : "us-east-1",
|
|
14
|
+
// ...api_keys
|
|
15
|
+
// }
|
|
16
|
+
// console.log(config)
|
|
17
|
+
// const utils = new TriangleUtils(config)
|
|
18
18
|
// const foods = await utils.dynamodb.query("triage_docket_documents:register_document_id", { register_document_id : "E6-17065" })
|
|
19
19
|
// console.log(foods)
|
|
20
20
|
// const text = await utils.bee.get("https://www.doyourjobs.org", { return_page_text : true })
|
|
21
21
|
// console.log(text)
|
|
22
22
|
// const text = await utils.bedrock.claude_invoke("global.anthropic.claude-opus-4-6-v1", "hi", undefined, { print_usage : true })
|
|
23
23
|
// console.log(text)
|
|
24
|
-
const url = "https://dataviewers.tdec.tn.gov/dataviewers/f?p=2005:34051:3300341444471:::34051:P34051_PERMIT_NUMBER:TNR136379"
|
|
25
|
-
const html = await utils.bee.get(url, { render_js: false })
|
|
26
|
-
console.log(html)
|
|
24
|
+
// const url = "https://dataviewers.tdec.tn.gov/dataviewers/f?p=2005:34051:3300341444471:::34051:P34051_PERMIT_NUMBER:TNR136379"
|
|
25
|
+
// const html = await utils.bee.get(url, { render_js : false })
|
|
26
|
+
// console.log(html)
|
|
27
|
+
// const prompt = "Is Mark Kelly a veteran?"
|
|
28
|
+
// console.log(prompt)
|
|
29
|
+
// const output = await utils.anthropic.claude_query("claude-opus-4-8",
|
|
30
|
+
// prompt,
|
|
31
|
+
// undefined,
|
|
32
|
+
// {
|
|
33
|
+
// print_usage : true,
|
|
34
|
+
// max_tokens : 20000,
|
|
35
|
+
// json_format : {
|
|
36
|
+
// type : "object",
|
|
37
|
+
// properties : {
|
|
38
|
+
// is_veteran : {
|
|
39
|
+
// type : "string"
|
|
40
|
+
// },
|
|
41
|
+
// explanation : {
|
|
42
|
+
// type : "string"
|
|
43
|
+
// }
|
|
44
|
+
// },
|
|
45
|
+
// required : ["is_veteran", "explanation"],
|
|
46
|
+
// additionalProperties : false
|
|
47
|
+
// },
|
|
48
|
+
// web : true
|
|
49
|
+
// }
|
|
50
|
+
// )
|
|
51
|
+
// console.log(output)
|
|
52
|
+
import { Client } from "@xdevplatform/xdk";
|
|
53
|
+
const x = new Client({ bearerToken: "AAAAAAAAAAAAAAAAAAAAAKoQ%2BQEAAAAAaej7PP534%2Fd9dKmieHRY6vQkv2s%3DyY2VerXmrA7w794ACFr9ALvoaJfuAHSlWwZdiDeVaOVpA6HCub" });
|
|
54
|
+
// const user = await x.users.getByUsername("Iam_award", { userFields : [
|
|
55
|
+
// "affiliation",
|
|
56
|
+
// // "confirmed_email",
|
|
57
|
+
// "connection_status",
|
|
58
|
+
// "created_at",
|
|
59
|
+
// "description",
|
|
60
|
+
// "entities",
|
|
61
|
+
// "id",
|
|
62
|
+
// "is_identity_verified",
|
|
63
|
+
// "location",
|
|
64
|
+
// "most_recent_tweet_id",
|
|
65
|
+
// "name",
|
|
66
|
+
// "parody",
|
|
67
|
+
// "pinned_tweet_id",
|
|
68
|
+
// "profile_banner_url",
|
|
69
|
+
// "profile_image_url",
|
|
70
|
+
// "protected",
|
|
71
|
+
// "public_metrics",
|
|
72
|
+
// // "receives_your_dm",
|
|
73
|
+
// "subscription",
|
|
74
|
+
// "subscription_type",
|
|
75
|
+
// "url",
|
|
76
|
+
// "username",
|
|
77
|
+
// "verified",
|
|
78
|
+
// "verified_followers_count",
|
|
79
|
+
// "verified_type",
|
|
80
|
+
// "withheld"
|
|
81
|
+
// ] })
|
|
82
|
+
// console.log(JSON.stringify(user, null, 4))
|
|
83
|
+
const tweets = await x.users.getPosts("0000000000184903215", { tweetFields: [
|
|
84
|
+
"article",
|
|
85
|
+
"attachments",
|
|
86
|
+
"author_id",
|
|
87
|
+
"card_uri",
|
|
88
|
+
"community_id",
|
|
89
|
+
"context_annotations",
|
|
90
|
+
"conversation_id",
|
|
91
|
+
"created_at",
|
|
92
|
+
"display_text_range",
|
|
93
|
+
"edit_controls",
|
|
94
|
+
"edit_history_tweet_ids",
|
|
95
|
+
"entities",
|
|
96
|
+
"geo",
|
|
97
|
+
"id",
|
|
98
|
+
"in_reply_to_user_id",
|
|
99
|
+
"lang",
|
|
100
|
+
"matched_media_notes",
|
|
101
|
+
"media_metadata",
|
|
102
|
+
"note_request_suggestions",
|
|
103
|
+
"note_tweet",
|
|
104
|
+
"paid_partnership",
|
|
105
|
+
"possibly_sensitive",
|
|
106
|
+
"referenced_tweets",
|
|
107
|
+
"reply_settings",
|
|
108
|
+
"scopes",
|
|
109
|
+
"source",
|
|
110
|
+
"suggested_source_links",
|
|
111
|
+
"suggested_source_links_with_counts",
|
|
112
|
+
"text",
|
|
113
|
+
"withheld"
|
|
114
|
+
] });
|
|
115
|
+
for (const tweet of tweets.data || []) {
|
|
116
|
+
console.log(JSON.stringify(tweet, undefined, 4));
|
|
117
|
+
}
|
|
118
|
+
// const tweet = await x.posts.getReposts("2068675973722128815")
|
|
119
|
+
// console.log(tweets)
|
package/dist/src/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { UtilsSES } from "./UtilsSES.js";
|
|
|
9
9
|
import { UtilsMisc } from "./UtilsMisc.js";
|
|
10
10
|
import { UtilsYoutube } from "./UtilsYoutube.js";
|
|
11
11
|
import { UtilsXAI } from "./UtilsXAI.js";
|
|
12
|
-
import { UtilsNitter } from "./UtilsNitter.js";
|
|
13
12
|
import { UtilsAnthropic } from "./UtilsAnthropic.js";
|
|
13
|
+
import { UtilsTwitter } from "./UtilsTwitter.js";
|
|
14
14
|
export declare class TriangleUtils extends UtilsMisc {
|
|
15
15
|
readonly dynamodb: UtilsDynamoDB;
|
|
16
16
|
readonly s3: UtilsS3;
|
|
@@ -22,7 +22,7 @@ export declare class TriangleUtils extends UtilsMisc {
|
|
|
22
22
|
readonly youtube: UtilsYoutube;
|
|
23
23
|
readonly anthropic: UtilsAnthropic;
|
|
24
24
|
readonly xai: UtilsXAI;
|
|
25
|
-
readonly
|
|
25
|
+
readonly twitter: UtilsTwitter;
|
|
26
26
|
constructor(config: TriangleUtilsConfig);
|
|
27
27
|
}
|
|
28
28
|
export * from "./types/TriangleUtilsConfig.js";
|
|
@@ -35,6 +35,6 @@ export * from "./UtilsBee.js";
|
|
|
35
35
|
export * from "./UtilsCognito.js";
|
|
36
36
|
export * from "./UtilsS3Vectors.js";
|
|
37
37
|
export * from "./UtilsSES.js";
|
|
38
|
-
export * from "./
|
|
38
|
+
export * from "./UtilsTwitter.js";
|
|
39
39
|
export * from "./UtilsXAI.js";
|
|
40
40
|
export * from "./UtilsYoutube.js";
|
package/dist/src/index.js
CHANGED
|
@@ -8,8 +8,8 @@ import { UtilsSES } from "./UtilsSES.js";
|
|
|
8
8
|
import { UtilsMisc } from "./UtilsMisc.js";
|
|
9
9
|
import { UtilsYoutube } from "./UtilsYoutube.js";
|
|
10
10
|
import { UtilsXAI } from "./UtilsXAI.js";
|
|
11
|
-
import { UtilsNitter } from "./UtilsNitter.js";
|
|
12
11
|
import { UtilsAnthropic } from "./UtilsAnthropic.js";
|
|
12
|
+
import { UtilsTwitter } from "./UtilsTwitter.js";
|
|
13
13
|
export class TriangleUtils extends UtilsMisc {
|
|
14
14
|
dynamodb;
|
|
15
15
|
s3;
|
|
@@ -21,7 +21,7 @@ export class TriangleUtils extends UtilsMisc {
|
|
|
21
21
|
youtube;
|
|
22
22
|
anthropic;
|
|
23
23
|
xai;
|
|
24
|
-
|
|
24
|
+
twitter;
|
|
25
25
|
constructor(config) {
|
|
26
26
|
super(config);
|
|
27
27
|
this.dynamodb = new UtilsDynamoDB(config.region);
|
|
@@ -34,7 +34,7 @@ export class TriangleUtils extends UtilsMisc {
|
|
|
34
34
|
this.youtube = new UtilsYoutube(config.youtube_api_key);
|
|
35
35
|
this.anthropic = new UtilsAnthropic(config.anthropic_api_key);
|
|
36
36
|
this.xai = new UtilsXAI(config.xai_api_key);
|
|
37
|
-
this.
|
|
37
|
+
this.twitter = new UtilsTwitter(config.twitter_api_key);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
export * from "./types/TriangleUtilsConfig.js";
|
|
@@ -47,6 +47,6 @@ export * from "./UtilsBee.js";
|
|
|
47
47
|
export * from "./UtilsCognito.js";
|
|
48
48
|
export * from "./UtilsS3Vectors.js";
|
|
49
49
|
export * from "./UtilsSES.js";
|
|
50
|
-
export * from "./
|
|
50
|
+
export * from "./UtilsTwitter.js";
|
|
51
51
|
export * from "./UtilsXAI.js";
|
|
52
52
|
export * from "./UtilsYoutube.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "triangle-utils",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.66",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"directories": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@types/jsdom": "^28.0.1",
|
|
28
28
|
"@types/node": "^25.2.3",
|
|
29
29
|
"@types/nodemailer": "^7.0.9",
|
|
30
|
+
"@xdevplatform/xdk": "^0.5.0",
|
|
30
31
|
"googleapis": "^170.0.0",
|
|
31
32
|
"jsdom": "^29.0.1",
|
|
32
33
|
"scrapingbee": "^1.8.2"
|
package/src/UtilsAnthropic.ts
CHANGED
|
@@ -14,7 +14,8 @@ export class UtilsAnthropic {
|
|
|
14
14
|
options : {
|
|
15
15
|
max_tokens? : number,
|
|
16
16
|
print_usage? : boolean,
|
|
17
|
-
json_format? : Record<string, any
|
|
17
|
+
json_format? : Record<string, any>,
|
|
18
|
+
web? : boolean
|
|
18
19
|
} = {}
|
|
19
20
|
) : Promise<string | undefined> {
|
|
20
21
|
try {
|
|
@@ -30,6 +31,7 @@ export class UtilsAnthropic {
|
|
|
30
31
|
}
|
|
31
32
|
]
|
|
32
33
|
})),
|
|
34
|
+
tools : options.web === true ? [{ name : "web_search", type : "web_search_20260209" }] : [],
|
|
33
35
|
max_tokens : options.max_tokens || 1000,
|
|
34
36
|
output_config : options.json_format !== undefined ? {
|
|
35
37
|
format : {
|
|
@@ -61,7 +63,8 @@ export class UtilsAnthropic {
|
|
|
61
63
|
options : {
|
|
62
64
|
max_tokens? : number,
|
|
63
65
|
print_usage? : boolean,
|
|
64
|
-
json_format? : Record<string, any
|
|
66
|
+
json_format? : Record<string, any>,
|
|
67
|
+
web? : boolean
|
|
65
68
|
} = {}
|
|
66
69
|
) : Promise<string | undefined> {
|
|
67
70
|
try {
|
|
@@ -93,6 +96,7 @@ export class UtilsAnthropic {
|
|
|
93
96
|
role : "user",
|
|
94
97
|
content : message_contents
|
|
95
98
|
}],
|
|
99
|
+
tools : options.web === true ? [{ name : "web_search", type : "web_search_20260209" }] : [],
|
|
96
100
|
max_tokens : options.max_tokens || 1000,
|
|
97
101
|
output_config : options.json_format !== undefined ? {
|
|
98
102
|
format : {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Client } from "@xdevplatform/xdk"
|
|
2
|
+
|
|
3
|
+
export class UtilsTwitter {
|
|
4
|
+
|
|
5
|
+
private readonly twitter : Client
|
|
6
|
+
|
|
7
|
+
constructor(twitter_api_key : string | undefined) {
|
|
8
|
+
this.twitter = new Client({ bearerToken : twitter_api_key })
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async get_user_by_username(username : string) : Promise<any> {
|
|
12
|
+
const result = await this.twitter.users.getByUsername(username, { userFields : [
|
|
13
|
+
"affiliation",
|
|
14
|
+
// "confirmed_email",
|
|
15
|
+
"connection_status",
|
|
16
|
+
"created_at",
|
|
17
|
+
"description",
|
|
18
|
+
"entities",
|
|
19
|
+
"id",
|
|
20
|
+
"is_identity_verified",
|
|
21
|
+
"location",
|
|
22
|
+
"most_recent_tweet_id",
|
|
23
|
+
"name",
|
|
24
|
+
"parody",
|
|
25
|
+
"pinned_tweet_id",
|
|
26
|
+
"profile_banner_url",
|
|
27
|
+
"profile_image_url",
|
|
28
|
+
"protected",
|
|
29
|
+
// "public_metrics",
|
|
30
|
+
// "receives_your_dm",
|
|
31
|
+
"subscription",
|
|
32
|
+
"subscription_type",
|
|
33
|
+
"url",
|
|
34
|
+
"username",
|
|
35
|
+
"verified",
|
|
36
|
+
"verified_followers_count",
|
|
37
|
+
"verified_type",
|
|
38
|
+
"withheld"
|
|
39
|
+
] })
|
|
40
|
+
.then(response => response.data)
|
|
41
|
+
return result
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async get_tweets(user_id : string) : Promise<any> {
|
|
45
|
+
const tweets = await this.twitter.users.getPosts(user_id, { tweetFields : [
|
|
46
|
+
"article",
|
|
47
|
+
"attachments",
|
|
48
|
+
"author_id",
|
|
49
|
+
"card_uri",
|
|
50
|
+
"community_id",
|
|
51
|
+
"context_annotations",
|
|
52
|
+
"conversation_id",
|
|
53
|
+
"created_at",
|
|
54
|
+
"display_text_range",
|
|
55
|
+
"edit_controls",
|
|
56
|
+
"edit_history_tweet_ids",
|
|
57
|
+
"entities",
|
|
58
|
+
"geo",
|
|
59
|
+
"id",
|
|
60
|
+
"in_reply_to_user_id",
|
|
61
|
+
"lang",
|
|
62
|
+
"matched_media_notes",
|
|
63
|
+
"media_metadata",
|
|
64
|
+
"note_request_suggestions",
|
|
65
|
+
"note_tweet",
|
|
66
|
+
"paid_partnership",
|
|
67
|
+
"possibly_sensitive",
|
|
68
|
+
"referenced_tweets",
|
|
69
|
+
"reply_settings",
|
|
70
|
+
"scopes",
|
|
71
|
+
"source",
|
|
72
|
+
"suggested_source_links",
|
|
73
|
+
"suggested_source_links_with_counts",
|
|
74
|
+
"text",
|
|
75
|
+
"withheld"
|
|
76
|
+
]})
|
|
77
|
+
.then(response => response.data)
|
|
78
|
+
return tweets
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/f.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { SecretsManager } from "@aws-sdk/client-secrets-manager"
|
|
2
|
-
import { TriangleUtils } from "."
|
|
1
|
+
// import { SecretsManager } from "@aws-sdk/client-secrets-manager"
|
|
2
|
+
// import { TriangleUtils } from "."
|
|
3
3
|
|
|
4
|
-
console.log("Starting triangle-utils!")
|
|
4
|
+
// console.log("Starting triangle-utils!")
|
|
5
5
|
|
|
6
|
-
const secret_name = "triage_config"
|
|
6
|
+
// const secret_name = "triage_config"
|
|
7
7
|
|
|
8
|
-
const secrets_manager = new SecretsManager({ region: "us-east-1" })
|
|
8
|
+
// const secrets_manager = new SecretsManager({ region: "us-east-1" })
|
|
9
9
|
|
|
10
|
-
const response = await secrets_manager.getSecretValue({
|
|
11
|
-
|
|
12
|
-
})
|
|
10
|
+
// const response = await secrets_manager.getSecretValue({
|
|
11
|
+
// SecretId: secret_name
|
|
12
|
+
// })
|
|
13
13
|
|
|
14
|
-
const api_keys = JSON.parse(response?.SecretString || "")
|
|
14
|
+
// const api_keys = JSON.parse(response?.SecretString || "")
|
|
15
15
|
|
|
16
|
-
const config = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
16
|
+
// const config = {
|
|
17
|
+
// google_email : "louishou@triangleanalytics.com",
|
|
18
|
+
// alerts_email : "alerts@triangleanalytics.com",
|
|
19
|
+
// region : "us-east-1",
|
|
20
|
+
// ...api_keys
|
|
21
|
+
// }
|
|
22
22
|
|
|
23
|
-
console.log(config)
|
|
23
|
+
// console.log(config)
|
|
24
24
|
|
|
25
|
-
const utils = new TriangleUtils(config)
|
|
25
|
+
// const utils = new TriangleUtils(config)
|
|
26
26
|
|
|
27
27
|
// const foods = await utils.dynamodb.query("triage_docket_documents:register_document_id", { register_document_id : "E6-17065" })
|
|
28
28
|
|
|
@@ -35,8 +35,112 @@ const utils = new TriangleUtils(config)
|
|
|
35
35
|
// const text = await utils.bedrock.claude_invoke("global.anthropic.claude-opus-4-6-v1", "hi", undefined, { print_usage : true })
|
|
36
36
|
// console.log(text)
|
|
37
37
|
|
|
38
|
-
const url = "https://dataviewers.tdec.tn.gov/dataviewers/f?p=2005:34051:3300341444471:::34051:P34051_PERMIT_NUMBER:TNR136379"
|
|
38
|
+
// const url = "https://dataviewers.tdec.tn.gov/dataviewers/f?p=2005:34051:3300341444471:::34051:P34051_PERMIT_NUMBER:TNR136379"
|
|
39
|
+
|
|
40
|
+
// const html = await utils.bee.get(url, { render_js : false })
|
|
41
|
+
|
|
42
|
+
// console.log(html)
|
|
43
|
+
|
|
44
|
+
// const prompt = "Is Mark Kelly a veteran?"
|
|
45
|
+
// console.log(prompt)
|
|
46
|
+
// const output = await utils.anthropic.claude_query("claude-opus-4-8",
|
|
47
|
+
// prompt,
|
|
48
|
+
// undefined,
|
|
49
|
+
// {
|
|
50
|
+
// print_usage : true,
|
|
51
|
+
// max_tokens : 20000,
|
|
52
|
+
// json_format : {
|
|
53
|
+
// type : "object",
|
|
54
|
+
// properties : {
|
|
55
|
+
// is_veteran : {
|
|
56
|
+
// type : "string"
|
|
57
|
+
// },
|
|
58
|
+
// explanation : {
|
|
59
|
+
// type : "string"
|
|
60
|
+
// }
|
|
61
|
+
// },
|
|
62
|
+
// required : ["is_veteran", "explanation"],
|
|
63
|
+
// additionalProperties : false
|
|
64
|
+
// },
|
|
65
|
+
// web : true
|
|
66
|
+
// }
|
|
67
|
+
// )
|
|
68
|
+
|
|
69
|
+
// console.log(output)
|
|
70
|
+
|
|
71
|
+
import { Client } from "@xdevplatform/xdk"
|
|
72
|
+
|
|
73
|
+
const x = new Client({ bearerToken : "AAAAAAAAAAAAAAAAAAAAAKoQ%2BQEAAAAAaej7PP534%2Fd9dKmieHRY6vQkv2s%3DyY2VerXmrA7w794ACFr9ALvoaJfuAHSlWwZdiDeVaOVpA6HCub" })
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// const user = await x.users.getByUsername("Iam_award", { userFields : [
|
|
77
|
+
// "affiliation",
|
|
78
|
+
// // "confirmed_email",
|
|
79
|
+
// "connection_status",
|
|
80
|
+
// "created_at",
|
|
81
|
+
// "description",
|
|
82
|
+
// "entities",
|
|
83
|
+
// "id",
|
|
84
|
+
// "is_identity_verified",
|
|
85
|
+
// "location",
|
|
86
|
+
// "most_recent_tweet_id",
|
|
87
|
+
// "name",
|
|
88
|
+
// "parody",
|
|
89
|
+
// "pinned_tweet_id",
|
|
90
|
+
// "profile_banner_url",
|
|
91
|
+
// "profile_image_url",
|
|
92
|
+
// "protected",
|
|
93
|
+
// "public_metrics",
|
|
94
|
+
// // "receives_your_dm",
|
|
95
|
+
// "subscription",
|
|
96
|
+
// "subscription_type",
|
|
97
|
+
// "url",
|
|
98
|
+
// "username",
|
|
99
|
+
// "verified",
|
|
100
|
+
// "verified_followers_count",
|
|
101
|
+
// "verified_type",
|
|
102
|
+
// "withheld"
|
|
103
|
+
// ] })
|
|
104
|
+
|
|
105
|
+
// console.log(JSON.stringify(user, null, 4))
|
|
106
|
+
|
|
107
|
+
const tweets = await x.users.getPosts("0000000000184903215", { tweetFields : [
|
|
108
|
+
"article",
|
|
109
|
+
"attachments",
|
|
110
|
+
"author_id",
|
|
111
|
+
"card_uri",
|
|
112
|
+
"community_id",
|
|
113
|
+
"context_annotations",
|
|
114
|
+
"conversation_id",
|
|
115
|
+
"created_at",
|
|
116
|
+
"display_text_range",
|
|
117
|
+
"edit_controls",
|
|
118
|
+
"edit_history_tweet_ids",
|
|
119
|
+
"entities",
|
|
120
|
+
"geo",
|
|
121
|
+
"id",
|
|
122
|
+
"in_reply_to_user_id",
|
|
123
|
+
"lang",
|
|
124
|
+
"matched_media_notes",
|
|
125
|
+
"media_metadata",
|
|
126
|
+
"note_request_suggestions",
|
|
127
|
+
"note_tweet",
|
|
128
|
+
"paid_partnership",
|
|
129
|
+
"possibly_sensitive",
|
|
130
|
+
"referenced_tweets",
|
|
131
|
+
"reply_settings",
|
|
132
|
+
"scopes",
|
|
133
|
+
"source",
|
|
134
|
+
"suggested_source_links",
|
|
135
|
+
"suggested_source_links_with_counts",
|
|
136
|
+
"text",
|
|
137
|
+
"withheld"
|
|
138
|
+
]})
|
|
139
|
+
|
|
140
|
+
for (const tweet of tweets.data || []) {
|
|
141
|
+
console.log(JSON.stringify(tweet, undefined, 4))
|
|
142
|
+
}
|
|
39
143
|
|
|
40
|
-
const
|
|
144
|
+
// const tweet = await x.posts.getReposts("2068675973722128815")
|
|
41
145
|
|
|
42
|
-
console.log(
|
|
146
|
+
// console.log(tweets)
|
package/src/index.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { UtilsSES } from "./UtilsSES"
|
|
|
9
9
|
import { UtilsMisc } from "./UtilsMisc"
|
|
10
10
|
import { UtilsYoutube } from "./UtilsYoutube"
|
|
11
11
|
import { UtilsXAI } from "./UtilsXAI"
|
|
12
|
-
import { UtilsNitter } from "./UtilsNitter"
|
|
13
12
|
import { UtilsAnthropic } from "./UtilsAnthropic"
|
|
13
|
+
import { UtilsTwitter } from "./UtilsTwitter"
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ export class TriangleUtils extends UtilsMisc {
|
|
|
26
26
|
readonly youtube : UtilsYoutube
|
|
27
27
|
readonly anthropic : UtilsAnthropic
|
|
28
28
|
readonly xai : UtilsXAI
|
|
29
|
-
readonly
|
|
29
|
+
readonly twitter : UtilsTwitter
|
|
30
30
|
|
|
31
31
|
constructor(config : TriangleUtilsConfig) {
|
|
32
32
|
super(config)
|
|
@@ -40,7 +40,7 @@ export class TriangleUtils extends UtilsMisc {
|
|
|
40
40
|
this.youtube = new UtilsYoutube(config.youtube_api_key)
|
|
41
41
|
this.anthropic = new UtilsAnthropic(config.anthropic_api_key)
|
|
42
42
|
this.xai = new UtilsXAI(config.xai_api_key)
|
|
43
|
-
this.
|
|
43
|
+
this.twitter = new UtilsTwitter(config.twitter_api_key)
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -54,6 +54,6 @@ export * from "./UtilsBee"
|
|
|
54
54
|
export * from "./UtilsCognito"
|
|
55
55
|
export * from "./UtilsS3Vectors"
|
|
56
56
|
export * from "./UtilsSES"
|
|
57
|
-
export * from "./
|
|
57
|
+
export * from "./UtilsTwitter"
|
|
58
58
|
export * from "./UtilsXAI"
|
|
59
59
|
export * from "./UtilsYoutube"
|