wirejs-deploy-amplify-basic 0.1.143-llm → 0.1.145-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.d.ts
CHANGED
package/dist/services/llm.js
CHANGED
|
@@ -6,6 +6,7 @@ export class LLM extends BaseLLM {
|
|
|
6
6
|
constructor(scope, id, options) {
|
|
7
7
|
super(scope, id, options);
|
|
8
8
|
this.models = options.models;
|
|
9
|
+
this.systemPrompt = options.systemPrompt;
|
|
9
10
|
this.bedrockClient = new BedrockRuntimeClient({
|
|
10
11
|
credentials: defaultProvider(),
|
|
11
12
|
});
|
|
@@ -18,7 +19,7 @@ export class LLM extends BaseLLM {
|
|
|
18
19
|
}
|
|
19
20
|
convertToBedrockFormat(messages) {
|
|
20
21
|
return messages.map(msg => ({
|
|
21
|
-
role: msg.role
|
|
22
|
+
role: msg.role,
|
|
22
23
|
content: [{
|
|
23
24
|
text: msg.content
|
|
24
25
|
}]
|
|
@@ -43,6 +44,9 @@ export class LLM extends BaseLLM {
|
|
|
43
44
|
const command = new ConverseStreamCommand({
|
|
44
45
|
modelId,
|
|
45
46
|
messages: this.convertToBedrockFormat(messages),
|
|
47
|
+
system: this.systemPrompt ? [{
|
|
48
|
+
text: this.systemPrompt
|
|
49
|
+
}] : undefined
|
|
46
50
|
});
|
|
47
51
|
return await this.bedrockClient.send(command);
|
|
48
52
|
}
|
|
@@ -50,6 +54,9 @@ export class LLM extends BaseLLM {
|
|
|
50
54
|
const command = new ConverseCommand({
|
|
51
55
|
modelId,
|
|
52
56
|
messages: this.convertToBedrockFormat(messages),
|
|
57
|
+
system: this.systemPrompt ? [{
|
|
58
|
+
text: this.systemPrompt
|
|
59
|
+
}] : undefined
|
|
53
60
|
});
|
|
54
61
|
return await this.bedrockClient.send(command);
|
|
55
62
|
}
|
|
@@ -125,6 +132,7 @@ export class LLM extends BaseLLM {
|
|
|
125
132
|
const result = await this.invokeModel(model, history, onChunk);
|
|
126
133
|
if (!result)
|
|
127
134
|
throw new Error("No response from model.");
|
|
135
|
+
return result;
|
|
128
136
|
}
|
|
129
137
|
catch (error) {
|
|
130
138
|
console.log(`Attempt failed with model: ${model}`);
|
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.145-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.145-llm"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@aws-amplify/backend": "^1.14.0",
|