wirejs-deploy-amplify-basic 0.1.138-llm → 0.1.140-llm
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/services/llm.js
CHANGED
|
@@ -19,7 +19,9 @@ export class LLM extends BaseLLM {
|
|
|
19
19
|
convertToBedrockFormat(messages) {
|
|
20
20
|
return messages.map(msg => ({
|
|
21
21
|
role: msg.role === 'user' ? 'user' : 'assistant',
|
|
22
|
-
content:
|
|
22
|
+
content: [{
|
|
23
|
+
text: msg.content
|
|
24
|
+
}]
|
|
23
25
|
}));
|
|
24
26
|
}
|
|
25
27
|
getModelId(model) {
|
|
@@ -93,6 +95,8 @@ export class LLM extends BaseLLM {
|
|
|
93
95
|
for (let i = 0; i < maxRetries; i++) {
|
|
94
96
|
try {
|
|
95
97
|
const modelId = this.getModelId(model);
|
|
98
|
+
if (modelId !== model)
|
|
99
|
+
console.log(`Mapped ${model} to ${modelId}`);
|
|
96
100
|
const response = await this.invokeBedrock(modelId, history, stream);
|
|
97
101
|
if (stream) {
|
|
98
102
|
return this.streamBedrock(response, onChunk);
|
|
@@ -128,7 +132,8 @@ export class LLM extends BaseLLM {
|
|
|
128
132
|
throw new Error("No response from model.");
|
|
129
133
|
}
|
|
130
134
|
catch (error) {
|
|
131
|
-
console.log(
|
|
135
|
+
console.log(`Attempt failed with model: ${model}`);
|
|
136
|
+
console.error(error);
|
|
132
137
|
if (error.name === 'ValidationException' && error.message?.includes('model')) {
|
|
133
138
|
continue;
|
|
134
139
|
}
|
|
@@ -137,7 +142,7 @@ export class LLM extends BaseLLM {
|
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
|
-
|
|
145
|
+
const message = this.createBedrockInstructionMessage(`None of the attempted are not available or not enabled in your AWS account. ` +
|
|
141
146
|
`Please enable it in the AWS Bedrock console:\n\n` +
|
|
142
147
|
`1. Go to AWS Bedrock Console (https://console.aws.amazon.com/bedrock/)\n` +
|
|
143
148
|
`2. Navigate to "Model access"\n` +
|
|
@@ -145,5 +150,18 @@ export class LLM extends BaseLLM {
|
|
|
145
150
|
`4. Accept the End User License Agreement (EULA)\n\n` +
|
|
146
151
|
`Available models attempted: ${this.models.join(', ')}\n` +
|
|
147
152
|
`You may need to enable these models: ${this.models.map(m => this.getModelId(m)).join(', ')}`);
|
|
153
|
+
if (onChunk) {
|
|
154
|
+
try {
|
|
155
|
+
onChunk({
|
|
156
|
+
message,
|
|
157
|
+
done: true,
|
|
158
|
+
created_at: new Date().toISOString()
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
console.error(error);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return message;
|
|
148
166
|
}
|
|
149
167
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wirejs-deploy-amplify-basic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.140-llm",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"recursive-copy": "^2.0.14",
|
|
45
45
|
"rimraf": "^6.0.1",
|
|
46
46
|
"wirejs-dom": "^1.0.42",
|
|
47
|
-
"wirejs-resources": "^0.1.
|
|
47
|
+
"wirejs-resources": "^0.1.140-llm"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@aws-amplify/backend": "^1.14.0",
|