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.
@@ -3,6 +3,6 @@
3
3
  "dependencies": {
4
4
  "jsdom": "^25.0.1",
5
5
  "wirejs-dom": "^1.0.42",
6
- "wirejs-resources": "^0.1.143-llm"
6
+ "wirejs-resources": "^0.1.145-llm"
7
7
  }
8
8
  }
@@ -3,6 +3,7 @@ export declare class LLM extends BaseLLM {
3
3
  private bedrockClient;
4
4
  constructor(scope: Resource | string, id: string, options: {
5
5
  models: string[];
6
+ systemPrompt?: string;
6
7
  });
7
8
  private createBedrockInstructionMessage;
8
9
  private convertToBedrockFormat;
@@ -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 === 'user' ? 'user' : 'assistant',
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.143-llm",
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.143-llm"
47
+ "wirejs-resources": "^0.1.145-llm"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@aws-amplify/backend": "^1.14.0",