triangle-utils 1.4.101 → 1.4.102
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 +51 -30
- package/package.json +1 -1
- package/src/UtilsBedrock.ts +51 -30
package/dist/src/UtilsBedrock.js
CHANGED
|
@@ -78,39 +78,60 @@ export class UtilsBedrock {
|
|
|
78
78
|
}
|
|
79
79
|
async claude_invoke(model_id, messages, options = {}) {
|
|
80
80
|
try {
|
|
81
|
-
const message_params = []
|
|
82
|
-
for (const message of messages) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
if (options.print) {
|
|
108
|
-
|
|
109
|
-
}
|
|
81
|
+
// const message_params : MessageParam[] = []
|
|
82
|
+
// for (const message of messages) {
|
|
83
|
+
// const content : ContentBlockParam[] = [
|
|
84
|
+
// {
|
|
85
|
+
// type : "text",
|
|
86
|
+
// text : message.text
|
|
87
|
+
// }
|
|
88
|
+
// ]
|
|
89
|
+
// if (message.pdf !== undefined) {
|
|
90
|
+
// content.push({
|
|
91
|
+
// type: "document",
|
|
92
|
+
// source: {
|
|
93
|
+
// type: "base64",
|
|
94
|
+
// media_type: "application/pdf",
|
|
95
|
+
// data: message.pdf
|
|
96
|
+
// },
|
|
97
|
+
// title: "Attachment",
|
|
98
|
+
// citations: { "enabled": false },
|
|
99
|
+
// cache_control: {"type": "ephemeral"}
|
|
100
|
+
// })
|
|
101
|
+
// }
|
|
102
|
+
// message_params.push({
|
|
103
|
+
// role : message.role,
|
|
104
|
+
// content : content
|
|
105
|
+
// })
|
|
106
|
+
// }
|
|
107
|
+
// if (options.print) {
|
|
108
|
+
// console.log("Constructed messages.")
|
|
109
|
+
// }
|
|
110
110
|
const request = {
|
|
111
111
|
modelId: model_id,
|
|
112
112
|
body: JSON.stringify({
|
|
113
|
-
messages:
|
|
113
|
+
messages: messages.map(message => ({
|
|
114
|
+
role: message.role,
|
|
115
|
+
content: [
|
|
116
|
+
{
|
|
117
|
+
type: "text",
|
|
118
|
+
text: message.text
|
|
119
|
+
},
|
|
120
|
+
...(message.pdf !== undefined ? [
|
|
121
|
+
{
|
|
122
|
+
type: "document",
|
|
123
|
+
source: {
|
|
124
|
+
type: "base64",
|
|
125
|
+
media_type: "application/pdf",
|
|
126
|
+
data: message.pdf
|
|
127
|
+
},
|
|
128
|
+
title: "Attachment",
|
|
129
|
+
citations: { "enabled": false },
|
|
130
|
+
cache_control: { "type": "ephemeral" }
|
|
131
|
+
}
|
|
132
|
+
] : [])
|
|
133
|
+
]
|
|
134
|
+
})),
|
|
114
135
|
system: options.system_prompt,
|
|
115
136
|
tools: options.web === true ? [{ name: "web_search", type: "web_search_20260209" }] : [],
|
|
116
137
|
max_tokens: options.max_tokens || 1000,
|
package/package.json
CHANGED
package/src/UtilsBedrock.ts
CHANGED
|
@@ -113,40 +113,61 @@ export class UtilsBedrock {
|
|
|
113
113
|
} = {}
|
|
114
114
|
) : Promise<string | undefined> {
|
|
115
115
|
try {
|
|
116
|
-
const message_params : MessageParam[] = []
|
|
117
|
-
for (const message of messages) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
116
|
+
// const message_params : MessageParam[] = []
|
|
117
|
+
// for (const message of messages) {
|
|
118
|
+
// const content : ContentBlockParam[] = [
|
|
119
|
+
// {
|
|
120
|
+
// type : "text",
|
|
121
|
+
// text : message.text
|
|
122
|
+
// }
|
|
123
|
+
// ]
|
|
124
|
+
// if (message.pdf !== undefined) {
|
|
125
|
+
// content.push({
|
|
126
|
+
// type: "document",
|
|
127
|
+
// source: {
|
|
128
|
+
// type: "base64",
|
|
129
|
+
// media_type: "application/pdf",
|
|
130
|
+
// data: message.pdf
|
|
131
|
+
// },
|
|
132
|
+
// title: "Attachment",
|
|
133
|
+
// citations: { "enabled": false },
|
|
134
|
+
// cache_control: {"type": "ephemeral"}
|
|
135
|
+
// })
|
|
136
|
+
// }
|
|
137
|
+
// message_params.push({
|
|
138
|
+
// role : message.role,
|
|
139
|
+
// content : content
|
|
140
|
+
// })
|
|
141
141
|
|
|
142
|
-
}
|
|
143
|
-
if (options.print) {
|
|
144
|
-
|
|
145
|
-
}
|
|
142
|
+
// }
|
|
143
|
+
// if (options.print) {
|
|
144
|
+
// console.log("Constructed messages.")
|
|
145
|
+
// }
|
|
146
146
|
const request = {
|
|
147
147
|
modelId : model_id,
|
|
148
148
|
body : JSON.stringify({
|
|
149
|
-
messages :
|
|
149
|
+
messages : messages.map(message => ({
|
|
150
|
+
role : message.role,
|
|
151
|
+
content : [
|
|
152
|
+
{
|
|
153
|
+
type : "text",
|
|
154
|
+
text : message.text
|
|
155
|
+
},
|
|
156
|
+
...(message.pdf !== undefined ? [
|
|
157
|
+
{
|
|
158
|
+
type: "document",
|
|
159
|
+
source: {
|
|
160
|
+
type: "base64",
|
|
161
|
+
media_type: "application/pdf",
|
|
162
|
+
data: message.pdf
|
|
163
|
+
},
|
|
164
|
+
title: "Attachment",
|
|
165
|
+
citations: { "enabled" : false },
|
|
166
|
+
cache_control: {"type": "ephemeral"}
|
|
167
|
+
}
|
|
168
|
+
] : [])
|
|
169
|
+
]
|
|
170
|
+
})),
|
|
150
171
|
system : options.system_prompt,
|
|
151
172
|
tools : options.web === true ? [{ name : "web_search", type : "web_search_20260209" }] : [],
|
|
152
173
|
max_tokens: options.max_tokens || 1000,
|